Update ctrl command parsing for python3
* make parse() return command id in addition to variable name and value
* introduce parse_kv() wrapper which ignores that id and use it instead
of old parse()
* make parse() compatible with python3 where we got bytes, not string
from the socket so we have to decode it properly before using split()
* expand test_py3.py with simply asyn server which verifies that
osmo_ctrl.py works properly
Change-Id: I599f9f5a18109929f59386ab4416b8bfd75c74d1
diff --git a/scripts/twisted_ipa.py b/scripts/twisted_ipa.py
index bb8323d..533bfae 100755
--- a/scripts/twisted_ipa.py
+++ b/scripts/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_kv(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)