From 98727bce3045161d3182adc1c51d0012720103ca Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Mon, 8 Oct 2018 17:36:24 +0100 Subject: [PATCH] utils/revent: recording parser fixes - change magic string literal to a b'' string so that the comparison works in python 3 - expand timestamp tuples (struct.unpack always returns a tuple) before attempting to cast to float. --- wa/utils/revent.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wa/utils/revent.py b/wa/utils/revent.py index 69ae24d1..2593bdd4 100644 --- a/wa/utils/revent.py +++ b/wa/utils/revent.py @@ -201,7 +201,7 @@ class ReventRecording(object): def _parse_header_and_devices(self, fh): magic, version = read_struct(fh, header_one_struct) - if magic != 'REVENT': + if magic != b'REVENT': msg = '{} does not appear to be an revent recording' raise ValueError(msg.format(self.filepath)) self.version = version @@ -216,11 +216,11 @@ class ReventRecording(object): raise ValueError('Unexpected recording mode: {}'.format(self.mode)) self.num_events, = read_struct(fh, u64_struct) if self.version > 2: - ts_sec = read_struct(fh, u64_struct) - ts_usec = read_struct(fh, u64_struct) + ts_sec = read_struct(fh, u64_struct)[0] + ts_usec = read_struct(fh, u64_struct)[0] self.start_time = datetime.fromtimestamp(ts_sec + float(ts_usec) / 1000000) - ts_sec = read_struct(fh, u64_struct) - ts_usec = read_struct(fh, u64_struct) + ts_sec = read_struct(fh, u64_struct)[0] + ts_usec = read_struct(fh, u64_struct)[0] self.end_time = datetime.fromtimestamp(ts_sec + float(ts_usec) / 1000000) elif 2 > self.version >= 0: