[svn] commit: r2104 - in /branches/trac172/src: bin/bind10/bind10.py.in lib/python/isc/cc/message.py lib/python/isc/cc/tests/Makefile.am lib/python/isc/cc/tests/message_test.py

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Jun 10 09:35:22 UTC 2010


Author: jelte
Date: Thu Jun 10 09:35:21 2010
New Revision: 2104

Log:
initial JSON usage on command channel in python.
to_wire simply returns an byte-encoded string representation of the objects in json format
from_wire translates that back to actual objects


Added:
    branches/trac172/src/lib/python/isc/cc/tests/message_test.py
Modified:
    branches/trac172/src/bin/bind10/bind10.py.in
    branches/trac172/src/lib/python/isc/cc/message.py
    branches/trac172/src/lib/python/isc/cc/tests/Makefile.am

Modified: branches/trac172/src/bin/bind10/bind10.py.in
==============================================================================
--- branches/trac172/src/bin/bind10/bind10.py.in (original)
+++ branches/trac172/src/bin/bind10/bind10.py.in Thu Jun 10 09:35:21 2010
@@ -272,41 +272,42 @@
         if self.verbose:
             sys.stdout.write("[bind10] ccsession started\n")
 
-        # start the xfrout before auth-server, to make sure every xfr-query can
-        # be processed properly.
-        xfrout_args = ['b10-xfrout']
-        if self.verbose:
-            sys.stdout.write("[bind10] Starting b10-xfrout\n")
-            xfrout_args += ['-v']
-        try:
-            xfrout = ProcessInfo("b10-xfrout", xfrout_args, 
-                                 c_channel_env )
-        except Exception as e:
-            c_channel.process.kill()
-            bind_cfgd.process.kill()
-            return "Unable to start b10-xfrout; " + str(e)
-        self.processes[xfrout.pid] = xfrout
-        if self.verbose:
-            sys.stdout.write("[bind10] Started b10-xfrout (PID %d)\n" % xfrout.pid)
-
-        # start b10-auth
-        # XXX: this must be read from the configuration manager in the future
-        authargs = ['b10-auth', '-p', str(self.auth_port)]
-        if self.verbose:
-            sys.stdout.write("[bind10] Starting b10-auth using port %d\n" %
-                             self.auth_port)
-            authargs += ['-v']
-        try:
-            auth = ProcessInfo("b10-auth", authargs,
-                               c_channel_env)
-        except Exception as e:
-            c_channel.process.kill()
-            bind_cfgd.process.kill()
-            xfrout.process.kill()
-            return "Unable to start b10-auth; " + str(e)
-        self.processes[auth.pid] = auth
-        if self.verbose:
-            sys.stdout.write("[bind10] Started b10-auth (PID %d)\n" % auth.pid)
+## TODO: UNCOMMENT (commented out, doing json for python first)
+#        # start the xfrout before auth-server, to make sure every xfr-query can
+#        # be processed properly.
+#        xfrout_args = ['b10-xfrout']
+#        if self.verbose:
+#            sys.stdout.write("[bind10] Starting b10-xfrout\n")
+#            xfrout_args += ['-v']
+#        try:
+#            xfrout = ProcessInfo("b10-xfrout", xfrout_args, 
+#                                 c_channel_env )
+#        except Exception as e:
+#            c_channel.process.kill()
+#            bind_cfgd.process.kill()
+#            return "Unable to start b10-xfrout; " + str(e)
+#        self.processes[xfrout.pid] = xfrout
+#        if self.verbose:
+#            sys.stdout.write("[bind10] Started b10-xfrout (PID %d)\n" % xfrout.pid)
+#
+#        # start b10-auth
+#        # XXX: this must be read from the configuration manager in the future
+#        authargs = ['b10-auth', '-p', str(self.auth_port)]
+#        if self.verbose:
+#            sys.stdout.write("[bind10] Starting b10-auth using port %d\n" %
+#                             self.auth_port)
+#            authargs += ['-v']
+#        try:
+#            auth = ProcessInfo("b10-auth", authargs,
+#                               c_channel_env)
+#        except Exception as e:
+#            c_channel.process.kill()
+#            bind_cfgd.process.kill()
+#            xfrout.process.kill()
+#            return "Unable to start b10-auth; " + str(e)
+#        self.processes[auth.pid] = auth
+#        if self.verbose:
+#            sys.stdout.write("[bind10] Started b10-auth (PID %d)\n" % auth.pid)
 
         # start b10-xfrin
         xfrin_args = ['b10-xfrin']

Modified: branches/trac172/src/lib/python/isc/cc/message.py
==============================================================================
--- branches/trac172/src/lib/python/isc/cc/message.py (original)
+++ branches/trac172/src/lib/python/isc/cc/message.py Thu Jun 10 09:35:21 2010
@@ -35,7 +35,15 @@
 _ITEM_LENGTH_8    = 0x20
 _ITEM_LENGTH_MASK = 0x30
 
+import json
+
 def to_wire(items):
+    return json.dumps(items).encode('utf8')
+
+def from_wire(data):
+    return json.loads(data.decode('utf8'))
+
+def old_to_wire(items):
     """Encode a dict into wire format.
     >>> wire_format = Message.to_wire({"a": "b"})
     """
@@ -140,7 +148,7 @@
 # decode methods
 #
 
-def from_wire(data):
+def old_from_wire(data):
     if len(data) < 5:
         raise DecodeError("Data is too short to decode")
     wire_version, data = data[0:4], data[4:]

Modified: branches/trac172/src/lib/python/isc/cc/tests/Makefile.am
==============================================================================
--- branches/trac172/src/lib/python/isc/cc/tests/Makefile.am (original)
+++ branches/trac172/src/lib/python/isc/cc/tests/Makefile.am Thu Jun 10 09:35:21 2010
@@ -1,4 +1,5 @@
-PYTESTS = data_test.py session_test.py test.py
+PYTESTS = message_test.py
+#data_test.py session_test.py test.py
 # NOTE: test_session.py is to be run manually, so not automated.
 EXTRA_DIST = $(PYTESTS)
 EXTRA_DIST += sendcmd.py




More information about the bind10-changes mailing list