summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal/MultiHook.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/internal/MultiHook.py')
-rw-r--r--module/plugins/internal/MultiHook.py68
1 files changed, 34 insertions, 34 deletions
diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py
index 22b0fd7c6..623836cdc 100644
--- a/module/plugins/internal/MultiHook.py
+++ b/module/plugins/internal/MultiHook.py
@@ -11,7 +11,7 @@ from module.utils import decode, remove_chars
class MultiHook(Hook):
__name__ = "MultiHook"
__type__ = "hook"
- __version__ = "0.49"
+ __version__ = "0.50"
__config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"),
("pluginlist" , "str" , "Plugin list (comma separated)", "" ),
@@ -65,10 +65,10 @@ class MultiHook(Hook):
self.pluginname = None
self.plugintype = None
- self.initPlugin()
+ self.init_plugin()
- def initPlugin(self):
+ def init_plugin(self):
self.pluginname = self.__name__.rsplit("Hook", 1)[0]
plugin, self.plugintype = self.core.pluginManager.findPlugin(self.pluginname)
@@ -76,47 +76,47 @@ class MultiHook(Hook):
self.pluginmodule = self.core.pluginManager.loadModule(self.plugintype, self.pluginname)
self.pluginclass = getattr(self.pluginmodule, self.pluginname)
else:
- self.logWarning("Hook plugin will be deactivated due missing plugin reference")
- self.setConfig('activated', False)
+ self.log_warning("Hook plugin will be deactivated due missing plugin reference")
+ self.set_config('activated', False)
- def loadAccount(self):
+ def load_account(self):
self.account = self.core.accountManager.getAccountPlugin(self.pluginname)
if self.account and not self.account.canUse():
self.account = None
if not self.account and hasattr(self.pluginclass, "LOGIN_ACCOUNT") and self.pluginclass.LOGIN_ACCOUNT:
- self.logWarning("Hook plugin will be deactivated due missing account reference")
- self.setConfig('activated', False)
+ self.log_warning("Hook plugin will be deactivated due missing account reference")
+ self.set_config('activated', False)
def activate(self):
self.init_periodical(threaded=True)
- def pluginsCached(self):
+ def plugins_cached(self):
if self.plugins:
return self.plugins
for _i in xrange(2):
try:
- pluginset = self._pluginSet(self.getHosters())
+ pluginset = self._plugin_set(self.get_hosters())
break
except Exception, e:
- self.logDebug(e, "Waiting 1 minute and retry")
+ self.log_debug(e, "Waiting 1 minute and retry")
time.sleep(60)
else:
- self.logWarning(_("Fallback to default reload interval due plugin parse error"))
+ self.log_warning(_("Fallback to default reload interval due plugin parse error"))
self.interval = self.MIN_RELOAD_INTERVAL
return list()
try:
- configmode = self.getConfig('pluginmode', 'all')
+ configmode = self.get_config('pluginmode', 'all')
if configmode in ("listed", "unlisted"):
- pluginlist = self.getConfig('pluginlist', '').replace('|', ',').replace(';', ',').split(',')
- configset = self._pluginSet(pluginlist)
+ pluginlist = self.get_config('pluginlist', '').replace('|', ',').replace(';', ',').split(',')
+ configset = self._plugin_set(pluginlist)
if configmode == "listed":
pluginset &= configset
@@ -124,14 +124,14 @@ class MultiHook(Hook):
pluginset -= configset
except Exception, e:
- self.logError(e)
+ self.log_error(e)
self.plugins = list(pluginset)
return self.plugins
- def _pluginSet(self, plugins):
+ def _plugin_set(self, plugins):
regexp = re.compile(r'^[\w\-.^_]{3,63}\.[a-zA-Z]{2,}$', re.U)
plugins = [decode(p.strip()).lower() for p in plugins if regexp.match(p.strip())]
@@ -143,7 +143,7 @@ class MultiHook(Hook):
return set(plugins)
- def getHosters(self):
+ def get_hosters(self):
"""
Load list of supported hoster
@@ -156,15 +156,15 @@ class MultiHook(Hook):
"""
Reload plugin list periodically
"""
- self.loadAccount()
+ self.load_account()
- if self.getConfig('reload', True):
- self.interval = max(self.getConfig('reloadinterval', 12) * 60 * 60, self.MIN_RELOAD_INTERVAL)
+ if self.get_config('reload', True):
+ self.interval = max(self.get_config('reloadinterval', 12) * 60 * 60, self.MIN_RELOAD_INTERVAL)
else:
self.core.scheduler.removeJob(self.cb)
self.cb = None
- self.logInfo(_("Reloading supported %s list") % self.plugintype)
+ self.log_info(_("Reloading supported %s list") % self.plugintype)
old_supported = self.supported
@@ -172,17 +172,17 @@ class MultiHook(Hook):
self.new_supported = []
self.plugins = []
- self.overridePlugins()
+ self.override_plugins()
old_supported = [plugin for plugin in old_supported if plugin not in self.supported]
if old_supported:
- self.logDebug("Unload: %s" % ", ".join(old_supported))
+ self.log_debug("Unload: %s" % ", ".join(old_supported))
for plugin in old_supported:
- self.unloadPlugin(plugin)
+ self.unload_plugin(plugin)
- def overridePlugins(self):
+ def override_plugins(self):
excludedList = []
if self.plugintype == "hoster":
@@ -192,7 +192,7 @@ class MultiHook(Hook):
pluginMap = {}
accountList = [name[::-1].replace("Folder"[::-1], "", 1).lower()[::-1] for name in self.core.pluginManager.crypterPlugins.iterkeys()]
- for plugin in self.pluginsCached():
+ for plugin in self.plugins_cached():
name = remove_chars(plugin, "-.")
if name in accountList:
@@ -204,11 +204,11 @@ class MultiHook(Hook):
self.new_supported.append(plugin)
if not self.supported and not self.new_supported:
- self.logError(_("No %s loaded") % self.plugintype)
+ self.log_error(_("No %s loaded") % self.plugintype)
return
#: inject plugin plugin
- self.logDebug("Overwritten %ss: %s" % (self.plugintype, ", ".join(sorted(self.supported))))
+ self.log_debug("Overwritten %ss: %s" % (self.plugintype, ", ".join(sorted(self.supported))))
for plugin in self.supported:
hdict = self.core.pluginManager.plugins[self.plugintype][plugin]
@@ -216,26 +216,26 @@ class MultiHook(Hook):
hdict['new_name'] = self.pluginname
if excludedList:
- self.logInfo(_("%ss not overwritten: %s") % (self.plugintype.capitalize(), ", ".join(sorted(excludedList))))
+ self.log_info(_("%ss not overwritten: %s") % (self.plugintype.capitalize(), ", ".join(sorted(excludedList))))
if self.new_supported:
plugins = sorted(self.new_supported)
- self.logDebug("New %ss: %s" % (self.plugintype, ", ".join(plugins)))
+ self.log_debug("New %ss: %s" % (self.plugintype, ", ".join(plugins)))
#: create new regexp
regexp = r'.*(?P<DOMAIN>%s).*' % "|".join(x.replace('.', '\.') for x in plugins)
if hasattr(self.pluginclass, "__pattern__") and isinstance(self.pluginclass.__pattern__, basestring) and "://" in self.pluginclass.__pattern__:
regexp = r'%s|%s' % (self.pluginclass.__pattern__, regexp)
- self.logDebug("Regexp: %s" % regexp)
+ self.log_debug("Regexp: %s" % regexp)
hdict = self.core.pluginManager.plugins[self.plugintype][self.pluginname]
hdict['pattern'] = regexp
hdict['re'] = re.compile(regexp)
- def unloadPlugin(self, plugin):
+ def unload_plugin(self, plugin):
hdict = self.core.pluginManager.plugins[self.plugintype][plugin]
if "module" in hdict:
hdict.pop('module', None)
@@ -250,7 +250,7 @@ class MultiHook(Hook):
Remove override for all plugins. Scheduler job is removed by hookmanager
"""
for plugin in self.supported:
- self.unloadPlugin(plugin)
+ self.unload_plugin(plugin)
#: reset pattern
hdict = self.core.pluginManager.plugins[self.plugintype][self.pluginname]