author | greg |
Mon, 18 May 2009 07:58:41 +0200 | |
changeset 345 | a3520d75a722 |
parent 298 | 732e30ac8bf3 |
child 399 | 77e23bf04c33 |
permissions | -rwxr-xr-x |
203 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
# |
|
4 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
|
5 |
# |
|
6 |
#See COPYING file for copyrights details. |
|
7 |
# |
|
8 |
#This library is free software; you can redistribute it and/or |
|
9 |
#modify it under the terms of the GNU General Public |
|
10 |
#License as published by the Free Software Foundation; either |
|
11 |
#version 2.1 of the License, or (at your option) any later version. |
|
12 |
# |
|
13 |
#This library is distributed in the hope that it will be useful, |
|
14 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
#General Public License for more details. |
|
17 |
# |
|
18 |
#You should have received a copy of the GNU General Public |
|
19 |
#License along with this library; if not, write to the Free Software |
|
20 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
||
22 |
# Package initialisation |
|
23 |
||
24 |
from os import listdir, path |
|
25 |
||
26 |
_base_path = path.split(__file__)[0] |
|
27 |
||
28 |
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("__")] |
|
29 |
||
30 |
def ConnectorFactory(uri, pluginsroot): |
|
31 |
""" |
|
32 |
Return a connector corresponding to the URI |
|
33 |
or None if cannot connect to URI |
|
34 |
""" |
|
35 |
servicetype = uri.split("://")[0] |
|
36 |
if servicetype in connector_types: |
|
37 |
# import module according to uri type |
|
38 |
connectormodule = getattr(__import__("connectors."+servicetype), servicetype) |
|
39 |
factoryname = servicetype + "_connector_factory" |
|
40 |
return getattr(connectormodule, factoryname)(uri, pluginsroot) |
|
227
48c13b84505c
- Some improovements in debug data feedback data
etisserant
parents:
203
diff
changeset
|
41 |
elif servicetype == "LOCAL": |
290
3bd617ae7a05
Local Runtime (LOCAL://) now launched "on demand"
etisserant
parents:
227
diff
changeset
|
42 |
#handle incompatibility with tray icon and svgui... |
298
732e30ac8bf3
Fixed the way LOCAL:// connector detects X11 poisoned plugins to avoid launching tray-icon enabled runtime (-x1)
etisserant
parents:
290
diff
changeset
|
43 |
poisoned_plugin = False |
732e30ac8bf3
Fixed the way LOCAL:// connector detects X11 poisoned plugins to avoid launching tray-icon enabled runtime (-x1)
etisserant
parents:
290
diff
changeset
|
44 |
for PlugIn in pluginsroot.IterChilds(): |
732e30ac8bf3
Fixed the way LOCAL:// connector detects X11 poisoned plugins to avoid launching tray-icon enabled runtime (-x1)
etisserant
parents:
290
diff
changeset
|
45 |
poisoned_plugin |= PlugIn.PlugType == "svgui" |
732e30ac8bf3
Fixed the way LOCAL:// connector detects X11 poisoned plugins to avoid launching tray-icon enabled runtime (-x1)
etisserant
parents:
290
diff
changeset
|
46 |
runtime_port = pluginsroot.AppFrame.StartLocalRuntime(taskbaricon = not poisoned_plugin) |
227
48c13b84505c
- Some improovements in debug data feedback data
etisserant
parents:
203
diff
changeset
|
47 |
import PYRO |
48c13b84505c
- Some improovements in debug data feedback data
etisserant
parents:
203
diff
changeset
|
48 |
return PYRO.PYRO_connector_factory( |
290
3bd617ae7a05
Local Runtime (LOCAL://) now launched "on demand"
etisserant
parents:
227
diff
changeset
|
49 |
"PYRO://127.0.0.1:"+str(runtime_port), |
227
48c13b84505c
- Some improovements in debug data feedback data
etisserant
parents:
203
diff
changeset
|
50 |
pluginsroot) |
203 | 51 |
else : |
52 |
return None |
|
53 |