diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-08-05 20:13:16 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-08-05 20:13:16 +0200 |
commit | 2dcf398b41b198823f058182b4460f83ca217aee (patch) | |
tree | cf3cd416f612757bc7b953e77999423b37744f86 | |
parent | api account fix (diff) | |
download | pyload-2dcf398b41b198823f058182b4460f83ca217aee.tar.xz |
fixes, closed #361
-rw-r--r-- | docs/access_api.rst | 2 | ||||
-rw-r--r-- | module/HookManager.py | 46 | ||||
-rw-r--r-- | module/PluginThread.py | 7 | ||||
-rw-r--r-- | module/common/packagetools.py | 3 | ||||
-rw-r--r-- | module/config/default.conf | 1 | ||||
-rw-r--r-- | module/plugins/Hook.py | 18 | ||||
-rw-r--r-- | module/plugins/container/LinkList.py | 2 | ||||
-rw-r--r-- | module/plugins/hooks/ExternalScripts.py | 18 | ||||
-rw-r--r-- | module/remote/RemoteManager.py | 7 | ||||
-rwxr-xr-x | pyLoadCli.py | 2 | ||||
-rwxr-xr-x | pyLoadCore.py | 1 |
11 files changed, 63 insertions, 44 deletions
diff --git a/docs/access_api.rst b/docs/access_api.rst index d70f120c3..c23a409bf 100644 --- a/docs/access_api.rst +++ b/docs/access_api.rst @@ -37,7 +37,7 @@ If every thing went fine you are ready to generate the method stubs, the command $thrift --gen (language) pyload.thrift You find now a directory named :file:`gen-(language)`. For instruction how to use the generated files consider the docs -at the thrift wiki and the examples here http://wiki.apache.org/thrift/ThriftUsage +at the thrift wiki and the examples here http://wiki.apache.org/thrift/ThriftUsage. Example 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) diff --git a/pyLoadCli.py b/pyLoadCli.py index 14ab64908..791f642ac 100755 --- a/pyLoadCli.py +++ b/pyLoadCli.py @@ -368,7 +368,7 @@ class Cli: elif status.status == 1: check = "Offline" else: check = "Unknown" - print "%-30s: %-30s %-8s\t %s" % (url, status.name, formatSize(status.size), check) + print "%-45s %-12s\t %-15s\t %s" % (status.name, formatSize(status.size), status.plugin, check) if result.rid == -1: break diff --git a/pyLoadCore.py b/pyLoadCore.py index 4220db302..7fcfc0f7a 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -211,6 +211,7 @@ class Core(object): pid = self.isAlreadyRunning() if not pid: print "No pyLoad running." + return try: os.kill(pid, 3) #SIGUIT |