- def runPlugin(self, plugin, session):
- try:
- exec "import " + self.prefix + plugin[2]
- eval(self.prefix + plugin[2]).main(session)
- except:
- print "exec of plugin failed!"
+ def readPluginList(self, directory, modules = [], depth = 1):
+ """enumerates plugins"""
+
+ directories = os.listdir(directory)
+
+ for x in directories:
+ path = directory + x + "/"
+ if os.path.isdir(path):
+ if fileExists(path + "plugin.py"):
+ plugin = my_import('.'.join(["Plugins"] + modules + [x, "plugin"]))
+
+ if not plugin.__dict__.has_key("Plugins"):
+ print "Plugin %s doesn't have 'Plugin'-call." % (x)
+ continue
+
+ plugins = plugin.Plugins()
+
+ # allow single entry not to be a list
+ if type(plugins) is not list:
+ plugins = [ plugins ]
+
+ for p in plugins:
+ p.updateIcon(path)
+ self.addPlugin(p);
+ else:
+ self.readPluginList(path, modules + [x], depth - 1)
+
+ def getPlugins(self, where):
+ """Get list of plugins in a specific category"""
+
+ if type(where) is not list:
+ where = [ where ]
+ res = [ ]
+ for x in where:
+ for p in self.plugins.get(x, [ ]):
+ res.append(p)
+ return res
+
+ def shutdown(self):
+ for p in self.pluginList[:]:
+ self.removePlugin(p)