Skip to content

Commit

Permalink
Dump as raw values
Browse files Browse the repository at this point in the history
It could be useful to perform some unusual transformations and pipe back to `whisper-update`
  • Loading branch information
Glandos authored and deniszh committed Oct 23, 2019
1 parent 300bef1 commit 60593a8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bin/whisper-dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
option_parser.add_option(
'-t', '--time-format', action='store', type='string', dest='time_format',
help='Time format to use with --pretty; see time.strftime()')
option_parser.add_option(
'-r', '--raw', default=False, action='store_true',
help='Dump value only in the same format for whisper-update (UTC timestamps)')
(options, args) = option_parser.parse_args()

if len(args) != 1:
Expand Down Expand Up @@ -101,7 +104,8 @@ def dump_archive_headers(archives):

def dump_archives(archives, options):
for i, archive in enumerate(archives):
print('Archive %d data:' % i)
if not options.raw:
print('Archive %d data:' % i)
offset = archive['offset']
for point in xrange(archive['points']):
(timestamp, value) = struct.unpack(
Expand All @@ -116,7 +120,10 @@ def dump_archives(archives, options):
timestr = time.ctime(timestamp)
else:
timestr = str(timestamp)
print('%d: %s, %10.35g' % (point, timestr, value))
if options.raw:
print('%s:%.35g' % (timestamp, value))
else:
print('%d: %s, %10.35g' % (point, timestr, value))
offset += whisper.pointSize
print

Expand All @@ -126,5 +133,6 @@ def dump_archives(archives, options):

map = mmap_file(path)
header = read_header(map)
dump_header(header)
if not options.raw:
dump_header(header)
dump_archives(header['archives'], options)

0 comments on commit 60593a8

Please sign in to comment.