From a6eda5244ee0ec4b3e8cea9cc17717a013d6d5b2 Mon Sep 17 00:00:00 2001 From: Sven Gestegard Robertz <sven.robertz@cs.lth.se> Date: Sat, 15 Feb 2014 20:27:32 +0100 Subject: [PATCH] fixed python encoding example for multiple labcomm versions --- examples/simple/example_encoder.py | 3 ++- examples/simple/run.sh | 4 ++++ lib/python/labcomm/LabComm.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/simple/example_encoder.py b/examples/simple/example_encoder.py index 4993373..277eb93 100755 --- a/examples/simple/example_encoder.py +++ b/examples/simple/example_encoder.py @@ -5,7 +5,8 @@ import sys import simple if __name__ == '__main__': - encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w'))) + version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2013" + encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')), version) encoder.add_decl(simple.theTwoInts.signature) encoder.add_decl(simple.IntString.signature) foo = simple.theTwoInts() diff --git a/examples/simple/run.sh b/examples/simple/run.sh index c8fd6d1..074b05c 100644 --- a/examples/simple/run.sh +++ b/examples/simple/run.sh @@ -25,6 +25,10 @@ echo java -cp .:../../lib/java:gen06 Encoder06 encoded_data06 ./example_decoder06 encoded_data06 + +PYTHONPATH=../../lib/python:gen ./example_encoder.py encoded_data06 LabComm2006 +java -cp .:../../lib/java:gen06 Decoder06 encoded_data06 + ./example_encoder06 encoded_data06 java -cp .:../../lib/java:gen06 Decoder06 encoded_data06 diff --git a/lib/python/labcomm/LabComm.py b/lib/python/labcomm/LabComm.py index 5b36d85..ad99579 100644 --- a/lib/python/labcomm/LabComm.py +++ b/lib/python/labcomm/LabComm.py @@ -556,7 +556,7 @@ class Encoder(Codec): def __init__(self, writer, version="LabComm2013"): super(Encoder, self).__init__() self.writer = writer - self.versoin = version + self.version = version self.writer.start(self, self.version) def pack(self, format, *args): -- GitLab