diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-02-08 02:10:34 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-02-08 02:15:58 +0100 |
commit | 3cea8ed5afb68060951cb20a6e07e3d0dca01e24 (patch) | |
tree | 1232e861fd6cef088ef6fb1e0cbc34bd1eb3a81d | |
parent | Spare code cosmetics (diff) | |
download | pyload-3cea8ed5afb68060951cb20a6e07e3d0dca01e24.tar.xz |
[ExternalScripts] Wait option
-rw-r--r-- | module/plugins/hooks/ExternalScripts.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index bbd442963..42f4ec481 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -12,9 +12,10 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.27" + __version__ = "0.28" - __config__ = [("activated", "bool", "Activated", True)] + __config__ = [("activated", "bool", "Activated" , True), + ("wait" , "bool", "Wait script ending", True)] __description__ = """Run external scripts""" __license__ = "GPLv3" @@ -58,6 +59,7 @@ class ExternalScripts(Hook): if not os.path.exists(path): try: os.makedirs(path) + except Exception: self.logDebug("Script folder %s not created" % folder) return @@ -75,9 +77,13 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: cmd = [script] + [str(x) if not isinstance(x, basestring) else x for x in args] + self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) - #output goes to pyload - subprocess.Popen(cmd, bufsize=-1) + + p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload + if self.getConfig('wait'): + p.communicate() + except Exception, e: self.logError(_("Error in %(script)s: %(error)s") % {"script": os.path.basename(script), "error": e}) |