summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-08-05 20:13:16 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-08-05 20:13:16 +0200
commit2dcf398b41b198823f058182b4460f83ca217aee (patch)
treecf3cd416f612757bc7b953e77999423b37744f86 /module
parentapi account fix (diff)
downloadpyload-2dcf398b41b198823f058182b4460f83ca217aee.tar.xz
fixes, closed #361
Diffstat (limited to 'module')
-rw-r--r--module/HookManager.py46
-rw-r--r--module/PluginThread.py7
-rw-r--r--module/common/packagetools.py3
-rw-r--r--module/config/default.conf1
-rw-r--r--module/plugins/Hook.py18
-rw-r--r--module/plugins/container/LinkList.py2
-rw-r--r--module/plugins/hooks/ExternalScripts.py18
-rw-r--r--module/remote/RemoteManager.py7
8 files changed, 60 insertions, 42 deletions
diff --git a/module/HookManager.py b/module/HookManager.py
index 5876debe4..464f5af99 100644
--- a/module/HookManager.py
+++ b/module/HookManager.py
@@ -39,28 +39,25 @@ class HookManager:
which provides additional entry point in the control flow.
Only do very short tasks or use threads.
- *Known Events:*
- All hook methods exists as events.
- downloadPreparing: A download was just queued and will be prepared now.
- Argument: fid
-
- downloadStarts: A plugin will immediately starts the download afterwards.
- Argument: fid
-
- linksAdded: Someone just added links, you are able to modify the links.
- Arguments: links, pid
-
- allDownloadsProcessed: Every link was handled, pyload would idle afterwards.
-
- allDownloadsFinished: Every download in queue is finished.
-
- Note: allDownloadsProcessed is *always* called before allDownloadsFinished.
-
- configChanged: The config was changed via the api.
-
- pluginConfigChanged: The plugin config changed, due to api or internal process.
-
- Note: pluginConfigChanged is always called after configChanged, if it affects plugins.
+ **Known Events:**
+ Most hook methods exists as events. These are the additional known events.
+
+ ===================== ============== ==================================
+ Name Arguments Description
+ ===================== ============== ==================================
+ downloadPreparing fid A download was just queued and will be prepared now.
+ downloadStarts fid A plugin will immediately starts the download afterwards.
+ linksAdded links, pid Someone just added links, you are able to modify the links.
+ allDownloadsProcessed Every link was handled, pyload would idle afterwards.
+ allDownloadsFinished Every download in queue is finished.
+ unrarFinished folder, fname An Unrar job finished
+ configChanged The config was changed via the api.
+ pluginConfigChanged The plugin config changed, due to api or internal process.
+ ===================== ============== ==================================
+
+ | Notes:
+ | allDownloadsProcessed is *always* called before allDownloadsFinished.
+ | configChanged is *always* called before pluginConfigChanged.
"""
@@ -200,6 +197,8 @@ class HookManager:
for plugin in self.plugins:
if plugin.isActivated():
plugin.coreReady()
+
+ self.dispatchEvent("coreReady")
self.initPeriodical()
@lock
@@ -250,9 +249,6 @@ class HookManager:
@lock
def unrarFinished(self, folder, fname):
- for plugin in self.plugins:
- plugin.unrarFinished(folder, fname)
-
self.dispatchEvent("unrarFinished", folder, fname)
def startThread(self, function, pyfile):
diff --git a/module/PluginThread.py b/module/PluginThread.py
index b415d7d60..be29a680e 100644
--- a/module/PluginThread.py
+++ b/module/PluginThread.py
@@ -600,8 +600,11 @@ class InfoThread(PluginThread):
pyfile.plugin.urls.extend(pack[1])
data = self.m.core.pluginManager.parseUrls(pyfile.plugin.urls)
- except :
- pass
+
+ self.m.log.debug("Got %d links." % len(data))
+
+ except Exception, e:
+ self.m.log.debug("Pre decrypting error: %s" % str(e))
finally:
pyfile.release()
diff --git a/module/common/packagetools.py b/module/common/packagetools.py
index 200f29c2f..5bfbcba95 100644
--- a/module/common/packagetools.py
+++ b/module/common/packagetools.py
@@ -53,6 +53,9 @@ def parseNames(files):
for file, url in files:
patternMatch = False
+ if file is None:
+ continue
+
# remove trailing /
name = file.rstrip('/')
diff --git a/module/config/default.conf b/module/config/default.conf
index 434e85a7c..8f5f98751 100644
--- a/module/config/default.conf
+++ b/module/config/default.conf
@@ -3,7 +3,6 @@ version: 1
remote - "Remote":
int port : "Port" = 7227
ip listenaddr : "Adress" = 0.0.0.0
- bool xmlrpc : "Activate old XMLRPC Backend" = False
bool nolocalauth : "No authentication on local connections" = True
ssl - "SSL":
bool activated : "Activated"= False
diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py
index 47faba95a..3db3e47e9 100644
--- a/module/plugins/Hook.py
+++ b/module/plugins/Hook.py
@@ -55,6 +55,11 @@ class Hook():
#: automatically register event listeners for functions, attribute will be deleted dont use it yourself
event_map = None
+ # Alternative to event_map
+ #: List of events the plugin can handle, name the functions exactly like eventname.
+ event_list = None # dont make duplicate entries in event_map
+
+
#: periodic call interval in secondc
interval = 60
@@ -78,8 +83,14 @@ class Hook():
else:
self.manager.addEvent(event, getattr(self,funcs))
- #delete for various reasons
- self.event_map = None
+ #delete for various reasons
+ self.event_map = None
+
+ if self.event_list:
+ for f in self.event_list:
+ self.manager.addEvent(f, getattr(self,f))
+
+ self.event_list = None
self.setup()
@@ -140,9 +151,6 @@ class Hook():
def periodical(self):
pass
- def unrarFinished(self, folder, fname):
- pass
-
def newCaptchaTask(self, task):
""" new captcha task for the plugin, it MUST set the handler and timeout or will be ignored """
pass
diff --git a/module/plugins/container/LinkList.py b/module/plugins/container/LinkList.py
index 22a63c78a..b9eb4b972 100644
--- a/module/plugins/container/LinkList.py
+++ b/module/plugins/container/LinkList.py
@@ -9,7 +9,7 @@ class LinkList(Container):
__version__ = "0.11"
__pattern__ = r".+\.txt$"
__description__ = """Read Link Lists in txt format"""
- __config__ = [("clear", "bool", "Clear Linklist after adding", True)]
+ __config__ = [("clear", "bool", "Clear Linklist after adding", False)]
__author_name__ = ("spoob", "jeix")
__author_mail__ = ("spoob@pyload.org", "jeix@hasnomail.com")
diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py
index 540b60477..36e026721 100644
--- a/module/plugins/hooks/ExternalScripts.py
+++ b/module/plugins/hooks/ExternalScripts.py
@@ -27,18 +27,20 @@ from module.utils import save_join
class ExternalScripts(Hook):
__name__ = "ExternalScripts"
- __version__ = "0.2"
- __description__ = """run external scripts"""
+ __version__ = "0.21"
+ __description__ = """Run external scripts"""
__config__ = [("activated", "bool", "Activated", "True")]
__author_name__ = ("mkaay", "RaNaN", "spoob")
__author_mail__ = ("mkaay@mkaay.de", "ranan@pyload.org", "spoob@pyload.org")
+ event_list = ["unrarFinished", "allDownloadsFinished", "allDownloadsProcessed"]
def setup(self):
self.scripts = {}
folders = ['download_preparing', 'download_finished', 'package_finished',
- 'before_reconnect', 'after_reconnect', 'unrar_finished']
+ 'before_reconnect', 'after_reconnect', 'unrar_finished',
+ 'all_dls_finished', 'all_dls_processed']
for folder in folders:
@@ -58,6 +60,7 @@ class ExternalScripts(Hook):
makedirs(path)
except :
self.logDebug("Script folder %s not created" % folder)
+ return
for f in listdir(path):
if f.startswith("#") or f.startswith(".") or f.startswith("_") or f.endswith("~") or f.endswith(".swp"):
@@ -105,3 +108,12 @@ class ExternalScripts(Hook):
def unrarFinished(self, folder, fname):
for script in self.scripts["unrar_finished"]:
self.callScript(script, folder, fname)
+
+ def allDownloadsFinished(self):
+ for script in self.scripts["all_dls_finished"]:
+ self.callScript(script)
+
+ def allDownloadsProcessed(self):
+ for script in self.scripts["all_dls_processed"]:
+ self.callScript(script)
+
diff --git a/module/remote/RemoteManager.py b/module/remote/RemoteManager.py
index 41c954419..792eaec4d 100644
--- a/module/remote/RemoteManager.py
+++ b/module/remote/RemoteManager.py
@@ -30,8 +30,8 @@ class BackendBase(Thread):
def run(self):
try:
self.serve()
- except:
- self.core.log.error(_("%s: Remote backend error") % self.__class__.__name__)
+ except Exception, e:
+ self.core.log.error(_("Remote backend error: %s") % e)
if self.core.debug:
print_exc()
@@ -59,9 +59,6 @@ class RemoteManager():
host = self.core.config["remote"]["listenaddr"]
port = self.core.config["remote"]["port"]
- if self.core.config["remote"]["xmlrpc"]:
- self.available.append("XMLRPCBackend")
-
for b in self.available:
klass = getattr(__import__("module.remote.%s" % b, globals(), locals(), [b] , -1), b)
backend = klass(self)