--- a/connectors/PYRO/__init__.py Mon Sep 21 12:12:08 2009 +0200
+++ b/connectors/PYRO/__init__.py Thu Sep 24 18:22:31 2009 +0200
@@ -24,6 +24,13 @@
from time import sleep
import copy
+# this module attribute contains a list of DNS-SD (Zeroconf) service types
+# supported by this connector plugin.
+#
+# for connectors that do not support DNS-SD, this attribute can be omitted
+# or set to an empty list.
+supported_dnssd_services = ["_PYRO._tcp.local."]
+
def PYRO_connector_factory(uri, pluginsroot):
"""
This returns the connector to Pyro style PLCobject
--- a/connectors/USB/__init__.py Mon Sep 21 12:12:08 2009 +0200
+++ b/connectors/USB/__init__.py Thu Sep 24 18:22:31 2009 +0200
@@ -19,4 +19,4 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from connector_USB import *
\ No newline at end of file
+from USB_connector import *
\ No newline at end of file
--- a/connectors/__init__.py Mon Sep 21 12:12:08 2009 +0200
+++ b/connectors/__init__.py Thu Sep 24 18:22:31 2009 +0200
@@ -23,9 +23,28 @@
from os import listdir, path
+import PYRO
+
_base_path = path.split(__file__)[0]
-connector_types = [name for name in listdir(_base_path) if path.isdir(path.join(_base_path, name)) and name.upper() != "CVS" and not name.startswith("__")]
+connector_types = [name for name in listdir(_base_path)
+ if path.isdir(path.join(_base_path, name))
+ and name.upper() != "CVS"
+ and not name.startswith("__")]
+
+# a dict from a URI scheme (connector name) to connector module
+connector_modules = {}
+
+# a dict from a DNS-SD service type to a connector module that support it
+dnssd_connectors = {}
+
+for t in connector_types:
+ new_module = getattr(__import__("connectors." + t), t)
+ connector_modules[t] = new_module
+
+ if hasattr(new_module, "supported_dnssd_services"):
+ for st in new_module.supported_dnssd_services:
+ dnssd_connectors[st] = new_module
def ConnectorFactory(uri, pluginsroot):
"""
@@ -35,16 +54,11 @@
servicetype = uri.split("://")[0]
if servicetype in connector_types:
# import module according to uri type
- connectormodule = getattr(__import__("connectors."+servicetype), servicetype)
+ connectormodule = connector_modules[servicetype]
factoryname = servicetype + "_connector_factory"
return getattr(connectormodule, factoryname)(uri, pluginsroot)
elif servicetype == "LOCAL":
- #handle incompatibility with tray icon and svgui...
- poisoned_plugin = False
- for PlugIn in pluginsroot.IterChilds():
- poisoned_plugin |= PlugIn.PlugType == "svgui"
- runtime_port = pluginsroot.AppFrame.StartLocalRuntime(taskbaricon = not poisoned_plugin)
- import PYRO
+ runtime_port = pluginsroot.AppFrame.StartLocalRuntime(taskbaricon=True)
return PYRO.PYRO_connector_factory(
"PYRO://127.0.0.1:"+str(runtime_port),
pluginsroot)
--- a/discovery.py Mon Sep 21 12:12:08 2009 +0200
+++ b/discovery.py Thu Sep 24 18:22:31 2009 +0200
@@ -21,10 +21,12 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import socket
import wx
+import wx.lib.mixins.listctrl as listmix
from Zeroconf import *
-import socket
-import wx.lib.mixins.listctrl as listmix
+
+import connectors
class AutoWidthListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
def __init__(self, parent, id, name, pos=wx.DefaultPosition,
@@ -117,21 +119,26 @@
self.nextItemId = 0
self.URI = None
- self.Browser = None
+ self.Browsers = []
self.ZeroConfInstance = Zeroconf()
self.RefreshList()
def __del__(self):
- self.Browser.cancel()
+ for browser in self.Browsers:
+ browser.cancel()
self.ZeroConfInstance.close()
def RefreshList(self):
- self.Browser = ServiceBrowser(self.ZeroConfInstance, "_PYRO._tcp.local.", self)
+ for browser in self.Browsers:
+ browser.cancel()
+
+ self.Browsers = []
+ for t in connectors.dnssd_connectors.keys():
+ self.Browsers.append(ServiceBrowser(self.ZeroConfInstance, t, self))
def OnRefreshButton(self, event):
self.ServicesList.DeleteAllItems()
- self.Browser.cancel()
self.RefreshList()
def OnLocalButton(self, event):