From b490547e656ad193abdd0ae337cd6b1338968b01 Mon Sep 17 00:00:00 2001 From: portnov Date: Fri, 6 Mar 2009 16:57:15 +0500 Subject: [PATCH] Fix import --- centrixd/cxcore.py | 9 ++++++++- centrixd/zeroconf.py | 5 +++-- test.py | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/centrixd/cxcore.py b/centrixd/cxcore.py index 3dfd835..f2cd6da 100644 --- a/centrixd/cxcore.py +++ b/centrixd/cxcore.py @@ -12,6 +12,7 @@ from cxutils import log from cxlogger import CXLogger from cxconfig import config import zeroconf +import data def on_sigint(signum, frame): print "Got SIGINT" @@ -28,8 +29,14 @@ mode = config['Centrix']['Mode'] master = (mode == 'Master') log("Entering %s mode" % mode) +zeroconf.services['proxy'] = data.Service() +zeroconf.services['proxy'].ip = '192.168.32.3' +zeroconf.services['proxy'].port = 3128 +zeroconf.services['gateway'] = data.Service() +zeroconf.services['gateway'].ip = '192.168.32.1' + if config['Network']['ZC Discover'] != False: - lock = zeroconf.discover(timeout=3000) + lock = zeroconf.discover(timeout=5000) print "Waiting for services discovery..." lock.acquire() print zeroconf.services diff --git a/centrixd/zeroconf.py b/centrixd/zeroconf.py index 3c3fc5b..d78f4bf 100644 --- a/centrixd/zeroconf.py +++ b/centrixd/zeroconf.py @@ -97,13 +97,14 @@ class ZeroconfThread(threading.Thread): b.connect_to_signal('ItemRemove', self.remove_service) def add_service(self, interface,proto,name,stype,domain,flags): - print "Found service:", name + print "Found service: %s/%s" % (stype,name) self.server.ResolveService(int(interface), int(proto), name,stype,domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), reply_handler = self.listener.new_service, error_handler = err) self.done[stype] = True if self._all_done(): + print "All services found." self.lock.release() def set_listener(self, ob): @@ -151,7 +152,7 @@ class ZeroconfListener(object): svc.ip = addr svc.port = port services[sname] = svc -# print "services[%s] = %s" % (sname, svc) + print "services[%s] = %s" % (sname, svc) def discover(services=('_ssh._tcp','_workstation._tcp','_nameserver._udp', '_centrix_master._tcp'),timeout=None): """Discover services of given types via zeroconf. diff --git a/test.py b/test.py index 8afd83f..fbe535a 100755 --- a/test.py +++ b/test.py @@ -14,7 +14,7 @@ import templates import configs import configsets from centrixd import data -import machines +from centrixd import machines # import xmlserialize as XML ##################################### -- 1.7.2.3