author | Edouard Tisserant |
Mon, 18 Nov 2013 12:12:31 +0900 | |
branch | 1.1 Korean release |
changeset 1384 | 02fe382c4511 |
parent 763 | c1104099c151 |
child 1440 | e8daabf2c438 |
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 |
||
399 | 26 |
|
203 | 27 |
_base_path = path.split(__file__)[0] |
28 |
||
399 | 29 |
|
733
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
30 |
def _GetLocalConnectorClassFactory(name): |
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
31 |
return lambda:getattr(__import__(name,globals(),locals()), name + "_connector_factory") |
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
32 |
|
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
33 |
connectors = {name:_GetLocalConnectorClassFactory(name) |
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
34 |
for name in listdir(_base_path) |
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
35 |
if path.isdir(path.join(_base_path, name)) |
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
36 |
and not name.startswith("__")} |
203 | 37 |
|
717 | 38 |
def ConnectorFactory(uri, confnodesroot): |
203 | 39 |
""" |
40 |
Return a connector corresponding to the URI |
|
41 |
or None if cannot connect to URI |
|
42 |
""" |
|
43 |
servicetype = uri.split("://")[0] |
|
733
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
44 |
if servicetype in connectors: |
203 | 45 |
# import module according to uri type |
733
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
46 |
connectorclass = connectors[servicetype]() |
227
48c13b84505c
- Some improovements in debug data feedback data
etisserant
parents:
203
diff
changeset
|
47 |
elif servicetype == "LOCAL": |
733
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
48 |
from PYRO import PYRO_connector_factory as connectorclass |
717 | 49 |
runtime_port = confnodesroot.AppFrame.StartLocalRuntime(taskbaricon=True) |
733
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
50 |
uri="PYRO://127.0.0.1:"+str(runtime_port) |
203 | 51 |
else : |
52 |
return None |
|
733
915be999f3f0
targets and connectors are nor extensible
Edouard Tisserant
parents:
717
diff
changeset
|
53 |
return connectorclass(uri, confnodesroot) |
203 | 54 |