Commit db8a6b60 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

port to python3 part 2.a

'fixed' imports by adding namespace to __init__.py files (is that right?)
still errors in session.py


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/f2f200910@161 e5f2f494-b856-4b98-b285-d166d9295462
parent 5b043005
......@@ -3,5 +3,5 @@
BINPATH=@abs_top_srcdir@/src/lib/bind-cfgd/python
LIBPATH=@abs_top_srcdir@/src/lib/cc/python
PYTHONPATH=${LIBPATH}:${PYTHONPATH} python ${BINPATH}/bind-cfgd.py
PYTHONPATH=${LIBPATH}:${PYTHONPATH} python3 ${BINPATH}/bind-cfgd.py
......@@ -21,12 +21,12 @@ class ConfigManager:
def add_zone(self, zone_name):
self.config.add_zone(zone_name, "todo")
print "sending update zone add"
print("sending update zone add")
self.cc.group_sendmsg({"zone_added": zone_name }, "ParkingLot")
def remove_zone(self, zone_name):
self.config.remove_zone(zone_name)
print "sending update zone del"
print("sending update zone del")
self.cc.group_sendmsg({"zone_deleted": zone_name }, "ParkingLot")
def read_config(self, filename):
......@@ -50,35 +50,35 @@ class ConfigManager:
elif cmd[0] == "zone" and cmd[1] == "list":
answer["result"] = self.config.zones.keys()
else:
print "unknown command: " + str(cmd)
print("unknown command: " + str(cmd))
answer["result"] = [ 1, "Unknown command: " + str(cmd) ]
except KeyError, ke:
print "unknown module: " + str(msg)
except KeyError as ke:
print("unknown module: " + str(msg))
answer["result"] = [ 1, "Unknown module: " + str(msg) ]
except IndexError, ie:
print "missing argument"
except IndexError as ie:
print("missing argument")
answer["result"] = [ 1, "Missing argument in command" ]
return answer
def run(self):
while (True):
msg, env = self.cc.group_recvmsg(False)
print "received message: "
print msg
print("received message: ")
print(msg)
answer = self.handle_msg(msg);
print "sending answer: "
print answer
print("sending answer: ")
print(answer)
self.cc.group_reply(env, answer)
print "answer sent"
print("answer sent")
pass
if __name__ == "__main__":
print "Hello, BIND10 world!"
print("Hello, BIND10 world!")
try:
cm = ConfigManager()
# do loading here if necessary
cm.notify_boss()
cm.run()
except ISC.CC.SessionError, se:
print "Error creating config manager, "\
"is the command channel daemon running?"
except ISC.CC.SessionError as se:
print("Error creating config manager, "
"is the command channel daemon running?")
import Message
from session import *
import ISC.CC.Message
from ISC.CC.session import *
......@@ -17,7 +17,7 @@ import sys
import socket
import struct
import Message
from ISC.CC import Message
class ProtocolError(Exception): pass
class NetworkError(Exception): pass
......
from hexdump import *
from ISC.Util.hexdump import *
import CC
import Util
import ISC.CC
import ISC.Util
......@@ -5,66 +5,66 @@ cc = ISC.CC.Session()
cc.group_subscribe("ConfigManager")
cmd = { "command": [ "zone", "add", "vix.com" ] }
print "Sending:"
print cmd
print("Sending:")
print(cmd)
cc.group_sendmsg(cmd, "ConfigManager")
data, routing = cc.group_recvmsg(False)
print "Answer:"
print data
print("Answer:")
print(data)
cmd = { "command": [ "zone", "add", "tjeb.nl" ] }
print "Sending:"
print cmd
print("Sending:")
print(cmd)
cc.group_sendmsg(cmd, "ConfigManager")
data, routing = cc.group_recvmsg(False)
print "Answer:"
print data
print("Answer:")
print(data)
cmd = { "command": [ "zone", "add", "flame.org" ] }
print "Sending:"
print cmd
print("Sending:")
print(cmd)
cc.group_sendmsg(cmd, "ConfigManager")
data, routing = cc.group_recvmsg(False)
print "Answer:"
print data
print("Answer:")
print(data)
cmd = { "command": [ "zone", "list" ] }
print "Sending:"
print cmd
print("Sending:")
print(cmd)
cc.group_sendmsg(cmd, "ConfigManager")
data, routing = cc.group_recvmsg(False)
print "Answer:"
print data
print("Answer:")
print(data)
cmd = { "command": [ "zone", "remove", "flame.org" ] }
print "Sending:"
print cmd
print("Sending:")
print(cmd)
cc.group_sendmsg(cmd, "ConfigManager")
data, routing = cc.group_recvmsg(False)
print "Answer:"
print data
print("Answer:")
print(data)
cmd = { "command": [ "zone", "list" ] }
print "Sending:"
print cmd
print("Sending:")
print(cmd)
cc.group_sendmsg(cmd, "ConfigManager")
data, routing = cc.group_recvmsg(False)
print "Answer:"
print data
print("Answer:")
print(data)
cmd = { "command": [ "zone", "bad_command", "foo" ] }
print "Sending:"
print cmd
print("Sending:")
print(cmd)
cc.group_sendmsg(cmd, "ConfigManager")
data, routing = cc.group_recvmsg(False)
print "Answer:"
print data
print("Answer:")
print(data)
cmd = { "command": [ "bad_module", "bad_command", "foo" ] }
print "Sending:"
print cmd
print("Sending:")
print(cmd)
cc.group_sendmsg(cmd, "ConfigManager")
data, routing = cc.group_recvmsg(False)
print "Answer:"
print data
print("Answer:")
print(data)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment