diff options
| author | acid-burn <acid-burn@opendreambox.org> | 2011-02-07 14:15:40 +0100 |
|---|---|---|
| committer | acid-burn <acid-burn@opendreambox.org> | 2011-02-07 14:15:40 +0100 |
| commit | 367c104e1d3716861c87905575d0bc729342d79c (patch) | |
| tree | 393b52b254228c6a89e858f646e6c7daaa38b389 /lib | |
| parent | 33e4aeedec7bde0b0f853396f7b308412bd85496 (diff) | |
| download | enigma2-367c104e1d3716861c87905575d0bc729342d79c.tar.gz enigma2-367c104e1d3716861c87905575d0bc729342d79c.zip | |
PluginSystem: implement new PluginDescriptor option "needsRestart" to define if a plugin needs an enigma2 restart after installation.
Now new installed plugins are only direct accessible after installation if needsRestart=False is defined inside the plugins PluginDescriptor.
fixes #670
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/python/Components/PluginComponent.py | 34 | ||||
| -rwxr-xr-x | lib/python/Plugins/Plugin.py | 3 |
2 files changed, 30 insertions, 7 deletions
diff --git a/lib/python/Components/PluginComponent.py b/lib/python/Components/PluginComponent.py index 5e439fdf..60f76738 100755 --- a/lib/python/Components/PluginComponent.py +++ b/lib/python/Components/PluginComponent.py @@ -8,6 +8,9 @@ from Plugins.Plugin import PluginDescriptor import keymapparser class PluginComponent: + firstRun = True + restartRequired = False + def __init__(self): self.plugins = {} self.pluginList = [ ] @@ -18,12 +21,22 @@ class PluginComponent: self.prefix = prefix def addPlugin(self, plugin): - self.pluginList.append(plugin) - for x in plugin.where: - self.plugins.setdefault(x, []).append(plugin) - if x == PluginDescriptor.WHERE_AUTOSTART: - plugin(reason=0) - + if self.firstRun: + self.pluginList.append(plugin) + for x in plugin.where: + self.plugins.setdefault(x, []).append(plugin) + if x == PluginDescriptor.WHERE_AUTOSTART: + plugin(reason=0) + else: + if plugin.needsRestart is False: + self.pluginList.append(plugin) + for x in plugin.where: + self.plugins.setdefault(x, []).append(plugin) + if x == PluginDescriptor.WHERE_AUTOSTART: + plugin(reason=0) + else: + self.restartRequired = True + def removePlugin(self, plugin): self.pluginList.remove(plugin) for x in plugin.where: @@ -81,12 +94,21 @@ class PluginComponent: # internally, the "fnc" argument will be compared with __eq__ plugins_added = [p for p in new_plugins if p not in self.pluginList] plugins_removed = [p for p in self.pluginList if not p.internal and p not in new_plugins] + + #ignore already installed but reloaded plugins + for p in plugins_removed: + for pa in plugins_added: + if pa.name == p.name and pa.where == p.where: + pa.needsRestart = False for p in plugins_removed: self.removePlugin(p) for p in plugins_added: self.addPlugin(p) + + if self.firstRun: + self.firstRun = False def getPlugins(self, where): """Get list of plugins in a specific category""" diff --git a/lib/python/Plugins/Plugin.py b/lib/python/Plugins/Plugin.py index 5a676cda..9ecdbc26 100755 --- a/lib/python/Plugins/Plugin.py +++ b/lib/python/Plugins/Plugin.py @@ -61,9 +61,10 @@ class PluginDescriptor: WHERE_SOFTWAREMANAGER = 14 - def __init__(self, name = "Plugin", where = [ ], description = "", icon = None, fnc = None, wakeupfnc = None, internal = False): + def __init__(self, name = "Plugin", where = [ ], description = "", icon = None, fnc = None, wakeupfnc = None, needsRestart = None, internal = False): self.name = name self.internal = internal + self.needsRestart = needsRestart if isinstance(where, list): self.where = where else: |
