diff options
author | Anders Broman <anders.broman@ericsson.com> | 2011-10-24 16:33:01 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2011-10-24 16:33:01 +0000 |
commit | a203843c86d9b5454fc39fd073e8c0655b75cd9f (patch) | |
tree | 3abeaf86baca1d3f16b277e192544345bb4f6411 /epan/wspython | |
parent | 3e136ab5bc0d2ae33080b7a872fef23db7bc801f (diff) |
From Eliot:
Search personal plugins dir for python plugins
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6448
svn path=/trunk/; revision=39534
Diffstat (limited to 'epan/wspython')
-rwxr-xr-x | epan/wspython/register-dissector.py | 51 | ||||
-rw-r--r-- | epan/wspython/wspy_register.c | 2 |
2 files changed, 30 insertions, 23 deletions
diff --git a/epan/wspython/register-dissector.py b/epan/wspython/register-dissector.py index 8a983e6f3b..a9ca3ac416 100755 --- a/epan/wspython/register-dissector.py +++ b/epan/wspython/register-dissector.py @@ -47,35 +47,42 @@ def plugin_import(name): except KeyError: pass - return __import__(name) + r = __import__(name) + return r -def register_dissectors(dir): +def register_dissectors(wspython_dir, plugins_pers_dir=None): #append dir to be able to import py_lib - sys.path.append(dir) + sys.path.append(wspython_dir) from wspy_libws import get_libws_handle libws = get_libws_handle() - dissectors_dir = os.path.join(dir, "wspy_dissectors") + dissectors_dirs = [ + os.path.join(wspython_dir, 'wspy_dissectors'), + plugins_pers_dir + ] - #Check if we have the dissectors directory - if not os.path.isdir(dissectors_dir): - return [] + registered_protocols = [] + for dissectors_dir in dissectors_dirs: + print 'looking for dissectors in', dissectors_dir + #Check if we have the dissectors directory + if not os.path.isdir(dissectors_dir): + continue - #append dir to be able to import python dissectors - sys.path.append(dissectors_dir) + #append dir to be able to import python dissectors + sys.path.append(dissectors_dir) - registered_protocols = [] - #Read all python dissectors - try: - dissectors = get_plugin_list(dissectors_dir, "(?P<plugin>.*)\.py$") - #For each dissector, register it and put it in the list of registered - #protocols - for dissector in dissectors: - d = plugin_import(dissector) - registered_protocol = d.register_protocol() - if registered_protocol: - registered_protocols.append(registered_protocol) - except Exception, e: - print e + #Read all python dissectors + dissectors = get_plugin_list(dissectors_dir, "(?P<plugin>.*)\.py$") + #For each dissector, register it and put it in the list of registered + #protocols + for dissector in dissectors: + try: + d = plugin_import(dissector) + registered_protocol = d.register_protocol() + if registered_protocol: + registered_protocols.append(registered_protocol) + except Exception, e: + print 'register dissector %s exception %s' % (dissector, e) + print 'registered protocols', registered_protocols return registered_protocols diff --git a/epan/wspython/wspy_register.c b/epan/wspython/wspy_register.c index 0df7e9eb46..97bde1b2f3 100644 --- a/epan/wspython/wspy_register.c +++ b/epan/wspython/wspy_register.c @@ -152,7 +152,7 @@ void register_all_py_protocols_func(void) /* Execute the python register function */ /* This function returns a sequence of python dissectors objects */ - py_args = Py_BuildValue("(s)", get_wspython_dir()); + py_args = Py_BuildValue("ss", get_wspython_dir(), get_plugins_pers_dir()); py_dissectors = PyObject_CallObject(register_fn, py_args); /* Check that the py_dissectors is really a sequence */ |