/usr/bin/whisper-diff is in python-whisper 0.9.15-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/usr/bin/python -tt
import sys
import optparse
try:
import whisper
except ImportError:
raise SystemExit('[ERROR] Please make sure whisper is installed properly')
option_parser = optparse.OptionParser(usage='''%prog [options] path_a path_b''')
option_parser.add_option('--summary', default=False, action='store_true',
help="show summary of differences")
option_parser.add_option('--ignore-empty', default=False, action='store_true',
help="skip comparison if either value is undefined")
option_parser.add_option('--columns', default=False, action='store_true',
help="print output in simple columns")
option_parser.add_option('--no-headers', default=False, action='store_true',
help="do not print column headers")
(options, args) = option_parser.parse_args()
if len(args) != 2:
option_parser.print_help()
sys.exit(1)
(path_a,path_b) = args[0::1]
def print_diffs(diffs,pretty=True,headers=True):
if pretty:
h = "%7s %11s %13s %13s\n"
f = "%7s %11d %13s %13s\n"
else:
h = "%s %s %s %s\n"
f = "%s %d %s %s\n"
if headers:
sys.stdout.write(h%('archive','timestamp','value_a','value_b'))
for archive, points, total in diffs:
count = count=points.__len__()
if pretty:
sys.stdout.write('Archive %d (%d of %d datapoints differ)\n'%(archive,points.__len__(),total))
sys.stdout.write(h%('','timestamp','value_a','value_b'))
for p in points:
if pretty:
sys.stdout.write(f%('',p[0],p[1],p[2]))
else:
sys.stdout.write(f%(archive,p[0],p[1],p[2]))
def print_summary(diffs,pretty=True,headers=True):
if pretty:
f = "%7s %9s %9s\n"
else:
f = "%s %s %s\n"
if headers:
sys.stdout.write(f%('archive','total','differing'))
for archive, points, total in diffs:
sys.stdout.write(f%(archive,total,points.__len__()))
archive_diffs = whisper.diff(path_a,path_b,ignore_empty=options.ignore_empty)
if options.summary:
print_summary(archive_diffs,pretty=(not options.columns),headers=(not options.no_headers))
else:
print_diffs(archive_diffs,pretty=(not options.columns),headers=(not options.no_headers))
|