summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r--module/plugins/hooks/ClickNLoad.py31
-rw-r--r--module/plugins/hooks/UpdateManager.py100
-rw-r--r--module/plugins/hooks/XFileSharing.py2
3 files changed, 68 insertions, 65 deletions
diff --git a/module/plugins/hooks/ClickNLoad.py b/module/plugins/hooks/ClickNLoad.py
index 722e4fbe0..79bf66c09 100644
--- a/module/plugins/hooks/ClickNLoad.py
+++ b/module/plugins/hooks/ClickNLoad.py
@@ -27,7 +27,7 @@ def forward(source, destination):
class ClickNLoad(Addon):
__name__ = "ClickNLoad"
__type__ = "hook"
- __version__ = "0.49"
+ __version__ = "0.51"
__status__ = "testing"
__config__ = [("activated", "bool" , "Activated" , True ),
@@ -37,19 +37,22 @@ class ClickNLoad(Addon):
__description__ = """Click'n'Load support"""
__license__ = "GPLv3"
- __authors__ = [("RaNaN" , "RaNaN@pyload.de" ),
- ("Walter Purcaro", "vuolter@gmail.com")]
+ __authors__ = [("RaNaN" , "RaNaN@pyload.de" ),
+ ("Walter Purcaro", "vuolter@gmail.com" ),
+ ("GammaC0de" , "nitzo2001[AT]yahoo[DOT]com")]
def activate(self):
if not self.pyload.config.get("webinterface", "activated"):
return
- ip = "" if self.get_config('extern') else "127.0.0.1"
- webport = self.pyload.config.get("webinterface", "port")
+ cnlip = "" if self.get_config('extern') else "127.0.0.1"
cnlport = self.get_config('port')
+ webip = "127.0.0.1" if any(_ip == self.pyload.config.get("webinterface", "host") for _ip in ("0.0.0.0", "")) \
+ else self.pyload.config.get("webinterface", "host")
+ webport = self.pyload.config.get("webinterface", "port")
- self.pyload.scheduler.addJob(5, self.proxy, [ip, webport, cnlport], threaded=False)
+ self.pyload.scheduler.addJob(5, self.proxy, [cnlip, cnlport, webip, webport], threaded=False)
@threaded
@@ -66,10 +69,10 @@ class ClickNLoad(Addon):
@threaded
- def proxy(self, ip, webport, cnlport):
- self.log_info(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport))
+ def proxy(self, cnlip, cnlport, webip, webport):
+ self.log_info(_("Proxy listening on %s:%s") % (cnlip or "0.0.0.0", cnlport))
- self._server(ip, webport, cnlport)
+ self._server(cnlip, cnlport, webip, webport)
lock = threading.Lock()
lock.acquire()
@@ -77,10 +80,10 @@ class ClickNLoad(Addon):
@threaded
- def _server(self, ip, webport, cnlport):
+ def _server(self, cnlip, cnlport, webip, webport):
try:
dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- dock_socket.bind((ip, cnlport))
+ dock_socket.bind((cnlip, cnlport))
dock_socket.listen(5)
while True:
@@ -103,16 +106,16 @@ class ClickNLoad(Addon):
client_socket.close()
continue
- server_socket.connect(("127.0.0.1", webport))
+ server_socket.connect((webip, webport))
self.forward(client_socket, server_socket, self.get_config('dest') is "queue")
self.forward(server_socket, client_socket)
except socket.timeout:
self.log_debug("Connection timed out, retrying...")
- return self._server(ip, webport, cnlport)
+ return self._server(cnlip, cnlport, webip, webport)
except socket.error, e:
self.log_error(e)
time.sleep(240)
- return self._server(ip, webport, cnlport)
+ return self._server(cnlip, cnlport, webip, webport)
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
diff --git a/module/plugins/hooks/XFileSharing.py b/module/plugins/hooks/XFileSharing.py
index 3c09fff4e..26dea3ec6 100644
--- a/module/plugins/hooks/XFileSharing.py
+++ b/module/plugins/hooks/XFileSharing.py
@@ -9,7 +9,7 @@ from module.plugins.internal.Addon import Addon
class XFileSharing(Addon):
__name__ = "XFileSharing"
__type__ = "hook"
- __version__ = "0.51"
+ __version__ = "0.52"
__status__ = "testing"
__config__ = [("activated" , "bool", "Activated" , True ),