diff options
| author | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-01-10 15:39:00 +0000 |
|---|---|---|
| committer | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-01-10 15:39:00 +0000 |
| commit | 91890bc31f2752aa8ff55372aa69a6723a0c09b5 (patch) | |
| tree | d9d558536109e919c410127a62b7873829f48df2 /lib/python/Components | |
| parent | f1515e774761f54062c718ef23361800df65accb (diff) | |
| download | enigma2-91890bc31f2752aa8ff55372aa69a6723a0c09b5.tar.gz enigma2-91890bc31f2752aa8ff55372aa69a6723a0c09b5.zip | |
move the plugins into their own directory and every plugin has a main python file called plugin.py in his directory
for example the update plugin now resides in /usr/lib/enigma2/python/Plugins/update
when you add a plugin, don't forget to put an empty __init__.py file into the directory, otherwise python doesn't recognize
the directory as module
Diffstat (limited to 'lib/python/Components')
| -rw-r--r-- | lib/python/Components/PluginComponent.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/python/Components/PluginComponent.py b/lib/python/Components/PluginComponent.py index 5315d3d9..0b407021 100644 --- a/lib/python/Components/PluginComponent.py +++ b/lib/python/Components/PluginComponent.py @@ -2,7 +2,6 @@ import os from Tools.Directories import * from Screens.Menu import menuupdater -#import Plugins class PluginComponent: def __init__(self): @@ -15,22 +14,27 @@ class PluginComponent: def getPluginList(self): list = [] - dir = os.listdir("/usr/lib/enigma2/python/Plugins/") + dir = os.listdir(resolveFilename(SCOPE_PLUGINS)) self.menuDelete() self.menuEntries = [] - for x in dir: - if x[-3:] == ".py" and x[:-3] != "__init__": - print "trying to import " + self.prefix + x[:-3] - exec "import " + self.prefix + x[:-3] - picturepath = eval(self.prefix + x[:-3]).getPicturePath() - pluginname = eval(self.prefix + x[:-3]).getPluginName() - try: - for menuEntry in eval(self.prefix + x[:-3]).getMenuRegistrationList(): - self.menuEntries.append([menuEntry, self.prefix + x[:-3]]) - except: - pass - list.append((picturepath, pluginname , x[:-3])) + for x in dir: + path = resolveFilename(SCOPE_PLUGINS, x) + "/" + 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) + picturepath = plugin.getPicturePath() + pluginname = plugin.getPluginName() + try: + for menuEntry in plugin.getMenuRegistrationList(): + self.menuEntries.append([menuEntry, pluginmodule]) + except: + pass + + list.append((picturepath, pluginname , x)) self.menuUpdate() return list @@ -44,8 +48,8 @@ class PluginComponent: def runPlugin(self, plugin, session): try: - exec "import " + self.prefix + plugin[2] - eval(self.prefix + plugin[2]).main(session) + exec "import " + self.prefix + plugin[2] + ".plugin" + eval(self.prefix + plugin[2] + ".plugin").main(session) except: print "exec of plugin failed!" |
