- try:
- if os.path.exists(path):
- if fileExists(path + "plugin.py"):
- pluginmodule = self.prefix + x + ".plugin"
- print "trying to import " + pluginmodule
- exec "import " + pluginmodule
- plugin = eval(pluginmodule)
- plugins = plugin.getPlugins()
- try: picturepaths = plugin.getPicturePaths()
- except:
- picturepaths = []
- for p in plugins:
- picturepaths.append("")
- try:
- for menuEntry in plugin.getMenuRegistrationList():
- self.menuEntries.append([menuEntry, pluginmodule])
- except:
- pass
-
- for y in range(len(plugins)):
- if len(plugins[y]) < 5:
- list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][2], plugins[y][3], None, plugins[y][1]))
- else:
- list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][2], plugins[y][3], plugins[y][4], plugins[y][1]))
- if runAutostartPlugins:
- try: plugin.autostart()
- except: pass
- if runAutoendPlugins:
- try: plugin.autoend()
- except: pass
- except:
- print "Directory", path, "contains a faulty plugin"
- self.menuUpdate()
- return list
-
- def menuDelete(self):
- for menuEntry in self.menuEntries:
- menuupdater.delMenuItem(menuEntry[0][0], menuEntry[0][1], menuEntry[0][2], menuEntry[1], menuEntry[0][3])
+ if os.path.exists(path):
+ if fileExists(path + "plugin.py"):
+ plugin = my_import('.'.join(("Plugins", x, "plugin")))
+
+ if not plugin.__dict__.has_key("Plugins"):
+ print "Plugin %s doesn't have 'Plugin'-call." % (x)
+ continue
+
+ print "plugin", plugin
+ plugins = plugin.Plugins()
+
+ # allow single entry not to be a list
+ if type(plugins) is not list:
+ plugins = [ plugins ]
+
+ for p in plugins:
+ print "imported plugin %s" % (p.name)
+
+ for x in p.where:
+ self.plugins.setdefault(x, []).append(p)