From f84b1bf5127989922cac000b304bef32601d74fb Mon Sep 17 00:00:00 2001 From: Viktor Kreschenski Date: Wed, 5 Feb 2020 16:07:25 +0100 Subject: [PATCH 1/3] Correct message iterator offset append --- format/OSITrace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format/OSITrace.py b/format/OSITrace.py index 06f453bfe..f93510829 100644 --- a/format/OSITrace.py +++ b/format/OSITrace.py @@ -142,7 +142,7 @@ def retrieve_message(self): message_length = struct.unpack(" Date: Wed, 5 Feb 2020 16:16:59 +0100 Subject: [PATCH 2/3] Added destructor and removed opening file twice --- format/OSITrace.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/format/OSITrace.py b/format/OSITrace.py index f93510829..85d8114f6 100644 --- a/format/OSITrace.py +++ b/format/OSITrace.py @@ -45,10 +45,8 @@ def __init__(self, path=None, type_name="SensorView"): self.timestep_count = 0 self.retrieved_scenario_size = 0 - if path is not None and type_name is not None: - self.from_file(path) - - # Open and Read text file + def __del__(self): + self.scenario_file.close() def from_file(self, path, type_name="SensorView", max_index=-1, format_type=None): """Import a scenario from a file""" From 4c74bfea91ab6a2d149c11fe0586ccef5d24bca0 Mon Sep 17 00:00:00 2001 From: Viktor Kreschenski Date: Tue, 11 Feb 2020 09:46:25 +0100 Subject: [PATCH 3/3] Added close of trace --- format/OSITrace.py | 3 --- format/osi2read.py | 3 ++- format/txt2osi.py | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/format/OSITrace.py b/format/OSITrace.py index 85d8114f6..f525d102c 100644 --- a/format/OSITrace.py +++ b/format/OSITrace.py @@ -45,9 +45,6 @@ def __init__(self, path=None, type_name="SensorView"): self.timestep_count = 0 self.retrieved_scenario_size = 0 - def __del__(self): - self.scenario_file.close() - def from_file(self, path, type_name="SensorView", max_index=-1, format_type=None): """Import a scenario from a file""" diff --git a/format/osi2read.py b/format/osi2read.py index 3c51a6973..4bab7cf00 100644 --- a/format/osi2read.py +++ b/format/osi2read.py @@ -56,7 +56,8 @@ def main(): if args.output == 'converted.txth': args.output = args.data.split('.', 1)[0] + '.txth' - trace.make_readable(args.output) + trace.make_readable(args.output) + trace.scenario_file.close() if __name__ == "__main__": main() \ No newline at end of file diff --git a/format/txt2osi.py b/format/txt2osi.py index 05a98592d..f7d9b5616 100644 --- a/format/txt2osi.py +++ b/format/txt2osi.py @@ -69,6 +69,7 @@ def main(): f.write(struct.pack("