[PATCH] python/osmo-python-tests[master]: Fix ctrl command parsing for python3

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Tue Nov 28 11:28:45 UTC 2017


Hello Neels Hofmeyr,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/5028

to look at the new patch set (#3).

Fix ctrl command parsing for python3

In python3 we got bytes, not string from the socket so we have to decode
it properly before using split().

Change-Id: I599f9f5a18109929f59386ab4416b8bfd75c74d1
---
M osmopy/osmo_ipa.py
M osmopy/twisted_ipa.py
2 files changed, 5 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/28/5028/3

diff --git a/osmopy/osmo_ipa.py b/osmopy/osmo_ipa.py
index 71cbf45..b5d11fc 100755
--- a/osmopy/osmo_ipa.py
+++ b/osmopy/osmo_ipa.py
@@ -28,7 +28,7 @@
     """
     Stateless IPA protocol multiplexer: add/remove/parse (extended) header
     """
-    version = "0.0.5"
+    version = "0.0.6"
     TCP_PORT_OML = 3002
     TCP_PORT_RSL = 3003
     # OpenBSC extensions: OSMO, MGCP_OLD
@@ -231,12 +231,13 @@
             return None
         return d
 
-    def parse(self, data, op=None):
+    def parse(self, raw_data, op=None):
         """
         Parse Ctrl string returning (var, value) pair
         var could be None in case of ERROR message
         value could be None in case of GET message
         """
+        data = self.rem_header(raw_data).decode('utf-8')
         (s, i, v) = data.split(' ', 2)
         if s == self.CTRL_ERR:
             return None, v
diff --git a/osmopy/twisted_ipa.py b/osmopy/twisted_ipa.py
index bb8323d..5bc6740 100755
--- a/osmopy/twisted_ipa.py
+++ b/osmopy/twisted_ipa.py
@@ -22,7 +22,7 @@
  */
 """
 
-__version__ = "0.7.0" # bump this on every non-trivial change
+__version__ = "0.7.1" # bump this on every non-trivial change
 
 from osmopy.osmo_ipa import Ctrl, IPA
 from twisted.internet.protocol import ReconnectingClientFactory
@@ -243,7 +243,7 @@
         OSMO CTRL message dispatcher, lambda default should never happen
         For basic tests only, appropriate handling routines should be replaced: see CtrlServer for example
         """
-        self.dbg('OSMO CTRL received %s::%s' % Ctrl().parse(data.decode('utf-8')))
+        self.dbg('OSMO CTRL received %s::%s' % Ctrl().parse(data))
         (cmd, op_id, v) = data.decode('utf-8').split(' ', 2)
         method = getattr(self, 'ctrl_' + cmd, lambda: "CTRL unknown command")
         method(data, op_id, v)

-- 
To view, visit https://gerrit.osmocom.org/5028
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I599f9f5a18109929f59386ab4416b8bfd75c74d1
Gerrit-PatchSet: 3
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list