summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar GammaC0de <GammaC0de@users.noreply.github.com> 2015-12-13 00:09:34 +0100
committerGravatar GammaC0de <GammaC0de@users.noreply.github.com> 2015-12-13 00:09:34 +0100
commitb281e900a5d5e7e7b8735c752c5f3faf2a36bb83 (patch)
tree701d9b9e70963d8be93cdcf1277ce0f688e68781
parent[RapiduNet] fix #2146 (diff)
downloadpyload-b281e900a5d5e7e7b8735c752c5f3faf2a36bb83.tar.xz
[UpdateManager] rename reserved words
-rw-r--r--module/plugins/hooks/UpdateManager.py100
1 files changed, 50 insertions, 50 deletions
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
index 13f8a3704..e235b0e47 100644
--- a/module/plugins/hooks/UpdateManager.py
+++ b/module/plugins/hooks/UpdateManager.py
@@ -15,7 +15,7 @@ from module.plugins.internal.utils import encode, exists, fs_join
class UpdateManager(Addon):
__name__ = "UpdateManager"
__type__ = "hook"
- __version__ = "1.03"
+ __version__ = "1.04"
__status__ = "testing"
__config__ = [("activated" , "bool", "Activated" , True ),
@@ -101,21 +101,21 @@ class UpdateManager(Addon):
m.__name__.count(".") >= 2, sys.modules.values()
)
for m in modules:
- root, type, name = m.__name__.rsplit(".", 2)
- id = (type, name)
- if type in self.pyload.pluginManager.plugins:
+ root, plugin_type, plugin_name = m.__name__.rsplit(".", 2)
+ plugin_id = (plugin_type, plugin_name)
+ if plugin_type in self.pyload.pluginManager.plugins:
f = m.__file__.replace(".pyc", ".py")
if not os.path.isfile(f):
continue
mtime = os.path.getmtime(f)
- if id not in self.mtimes:
- self.mtimes[id] = mtime
+ if plugin_id not in self.mtimes:
+ self.mtimes[plugin_id] = mtime
- elif self.mtimes[id] < mtime:
- reloads.append(id)
- self.mtimes[id] = mtime
+ elif self.mtimes[plugin_id] < mtime:
+ reloads.append(plugin_id)
+ self.mtimes[plugin_id] = mtime
return True if self.pyload.pluginManager.reloadPlugins(reloads) else False
@@ -186,12 +186,12 @@ class UpdateManager(Addon):
@Expose
def update_plugins(self):
- updates = self.server_response()
+ server_data = self.server_response()
- if not updates or updates[0] != "None":
+ if not server_data or server_data[0] != "None":
return 0
- updated = self._update_plugins(updates)
+ updated = self._update_plugins(server_data)
if updated:
self.log_info(_("*** Plugins updated ***"))
@@ -215,15 +215,15 @@ class UpdateManager(Addon):
return exitcode
- def parse_list(self, list):
- schema = list[2].split('|')
+ def parse_updates(self, server_data):
+ schema = server_data[2].split('|')
- if "BLACKLIST" in list:
- blacklist = list[list.index('BLACKLIST') + 1:]
- updatelist = list[3:list.index('BLACKLIST')]
+ if "BLACKLIST" in server_data:
+ blacklist = server_data[server_data.index('BLACKLIST') + 1:]
+ updatelist = server_data[3:server_data.index('BLACKLIST')]
else:
blacklist = []
- updatelist = list[3:]
+ updatelist = server_data[3:]
for l in updatelist, blacklist:
nl = []
@@ -239,51 +239,51 @@ class UpdateManager(Addon):
return updatelist, blacklist
- def _update_plugins(self, updates):
+ def _update_plugins(self, server_data):
"""
Check for plugin updates
"""
updated = []
- updatelist, blacklist = self.parse_list(updates)
+ updatelist, blacklist = self.parse_updates(server_data)
- url = updates[1]
+ url = server_data[1]
req = self.pyload.requestFactory.getRequest(self.classname)
if blacklist:
#@NOTE: Protect UpdateManager from self-removing
- type_plugins = [(plugin['type'], plugin['name']) for plugin in blacklist \
+ blacklisted_plugins = [(plugin['type'], plugin['name']) for plugin in blacklist \
if plugin['name'] is not self.classname and plugin['type'] is not self.__type__]
c = 1
- l = len(type_plugins)
+ l = len(blacklisted_plugins)
for idx, plugin in enumerate(updatelist):
if c > l:
break
- name = plugin['name']
- type = plugin['type']
- for t, n in type_plugins:
- if n != name or t != type:
+ plugin_name = plugin['name']
+ plugin_type = plugin['type']
+ for t, n in blacklisted_plugins:
+ if n != plugin_name or t != plugin_type:
continue
updatelist.pop(idx)
c += 1
break
- for t, n in self.remove_plugins(type_plugins):
+ for t, n in self.remove_plugins(blacklisted_plugins):
self.log_info(_("Removed blacklisted plugin: %(type)s %(name)s") % {
'type': t.upper(),
'name': n,
})
for plugin in updatelist:
- name = plugin['name']
- type = plugin['type']
- version = plugin['version']
+ plugin_name = plugin['name']
+ plugin_type = plugin['type']
+ plugin_version = plugin['version']
- plugins = getattr(self.pyload.pluginManager, "%sPlugins" % type.rstrip('s')) #@TODO: Remove rstrip in 0.4.10
+ plugins = getattr(self.pyload.pluginManager, "%sPlugins" % plugin_type.rstrip('s')) #@TODO: Remove rstrip in 0.4.10
- oldver = float(plugins[name]['v']) if name in plugins else None
- newver = float(version)
+ oldver = float(plugins[plugin_name]['v']) if plugin_name in plugins else None
+ newver = float(plugin_version)
if not oldver:
msg = "New plugin: %(type)s %(name)s (v%(newver).2f)"
@@ -292,8 +292,8 @@ class UpdateManager(Addon):
else:
continue
- self.log_info(_(msg) % {'type' : type.rstrip('s').upper(), #@TODO: Remove rstrip in 0.4.10
- 'name' : name,
+ self.log_info(_(msg) % {'type' : plugin_type.rstrip('s').upper(), #@TODO: Remove rstrip in 0.4.10
+ 'name' : plugin_name,
'oldver': oldver,
'newver': newver})
try:
@@ -303,16 +303,16 @@ class UpdateManager(Addon):
raise Exception(_("URL not found"))
m = self._VERSION.search(content)
- if m and m.group(2) == version:
- with open(fs_join("userplugins", type, name + ".py"), "wb") as f:
+ if m and m.group(2) == plugin_version:
+ with open(fs_join("userplugins", plugin_type, plugin_name + ".py"), "wb") as f:
f.write(encode(content))
- updated.append((type, name))
+ updated.append((plugin_type, plugin_name))
else:
raise Exception(_("Version mismatch"))
except Exception, e:
- self.log_error(_("Error updating plugin: %s %s") % (type.rstrip('s').upper(), name), e) #@TODO: Remove rstrip in 0.4.10
+ self.log_error(_("Error updating plugin: %s %s") % (plugin_type.rstrip('s').upper(), plugin_name), e) #@TODO: Remove rstrip in 0.4.10
return updated
@@ -327,27 +327,27 @@ class UpdateManager(Addon):
@Expose
- def remove_plugins(self, type_plugins):
+ def remove_plugins(self, plugin_ids):
"""
Delete plugins from disk
"""
- if not type_plugins:
+ if not plugin_ids:
return
removed = set()
- self.log_debug("Requested deletion of plugins: %s" % type_plugins)
+ self.log_debug("Requested deletion of plugins: %s" % plugin_ids)
- for type, name in type_plugins:
+ for plugin_type, plugin_name in plugin_ids:
rootplugins = os.path.join(pypath, "module", "plugins")
- for dir in ("userplugins", rootplugins):
- py_filename = fs_join(dir, type, name + ".py")
+ for basedir in ("userplugins", rootplugins):
+ py_filename = fs_join(basedir, plugin_type, plugin_name + ".py")
pyc_filename = py_filename + "c"
- if type is "hook":
+ if plugin_type is "hook":
try:
- self.manager.deactivateHook(name)
+ self.manager.deactivateHook(plugin_name)
except Exception, e:
self.log_debug(e, trace=True)
@@ -363,7 +363,7 @@ class UpdateManager(Addon):
self.log_warning(_("Error removing `%s`") % filename, e)
else:
- id = (type, name)
- removed.add(id)
+ plugin_id = (plugin_type, plugin_name)
+ removed.add(plugin_id)
return list(removed) #: Return a list of the plugins successfully removed