diff options
author | Jeix <devnull@localhost> | 2010-06-20 13:07:24 +0200 |
---|---|---|
committer | Jeix <devnull@localhost> | 2010-06-20 13:07:24 +0200 |
commit | 29241018fe7338a88d01a0c37f0a3f9e45b8d6f3 (patch) | |
tree | a83d47660de94bb79cfaf2f0ac2c6ac618a5d061 /module | |
parent | Debug = False is the better choice as default (diff) | |
download | pyload-29241018fe7338a88d01a0c37f0a3f9e45b8d6f3.tar.xz |
Package_finished event for scripts implemented
bugfix: closing socket for IRC connection (xdcc)
Diffstat (limited to 'module')
-rw-r--r-- | module/HookManager.py | 8 | ||||
-rw-r--r-- | module/ThreadManager.py | 9 | ||||
-rw-r--r-- | module/network/XdccRequest.py | 3 | ||||
-rw-r--r-- | module/plugins/hooks/ExternalScripts.py | 9 |
4 files changed, 23 insertions, 6 deletions
diff --git a/module/HookManager.py b/module/HookManager.py index f5835bce0..bb08fff4a 100644 --- a/module/HookManager.py +++ b/module/HookManager.py @@ -73,8 +73,12 @@ class HookManager(): plugin.downloadFinished(pyfile) self.lock.release() - def packageFinished(self, pyfile, package): - raise NotImplementedError + def packageFinished(self, package): + self.lock.acquire() + + for plugin in self.plugins: + plugin.packageFinished(package) + self.lock.release() def beforeReconnecting(self, ip): self.lock.acquire() diff --git a/module/ThreadManager.py b/module/ThreadManager.py index 307728fb3..1c5a89a5c 100644 --- a/module/ThreadManager.py +++ b/module/ThreadManager.py @@ -179,7 +179,16 @@ class ThreadManager(Thread): #~ pyfile.packager.pullOutPackage(pyfile.package.id) #~ pyfile.packager.addFileToPackage(pyfile.package.id, pyfile.collector.popFile(id)) else: + packFinished = True + for packfile in pyfile.package.files: + if packfile.status.type != "finished": + packFinished = False + break + self.parent.logger.info(_("Download finished: %s") % pyfile.url) + if packFinished: + self.parent.logger.info(_("Package finished: %s") % pyfile.package.data['package_name']) + self.parent.hookManager.packageFinished(pyfile.package) elif pyfile.status.type == "reconnected": pyfile.plugin.req.init_curl() diff --git a/module/network/XdccRequest.py b/module/network/XdccRequest.py index 57fdced66..bf9965eba 100644 --- a/module/network/XdccRequest.py +++ b/module/network/XdccRequest.py @@ -25,6 +25,7 @@ import time import socket
from select import select
import re
+from os import sep, rename, stat
from os.path import exists
import struct
@@ -181,6 +182,7 @@ class XdccRequest: # kill IRC socket
sock.send("QUIT :byebye\r\n")
+ sock.close()
# connect to XDCC Bot
dcc = socket.socket()
@@ -225,6 +227,7 @@ class XdccRequest: # acknowledge data by sending number of recceived bytes
dcc.send(struct.pack('!I', dcc_total))
########################
+
free_name = self.get_free_name(dcc_packname)
rename(dcc_packname + ".part", free_name)
diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 9e0f3855c..6a45cdace 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -80,10 +80,11 @@ class ExternalScripts(Hook): pass def packageFinished(self, pypack): - """ - not implemented! - """ - pass + for script in self.scripts['package_finished']: + try: + out = subprocess.Popen([join(self.folder, 'package_finished', script), pypack.data['package_name'], pypack.data['folder']], stdout=subprocess.PIPE) + except: + pass def beforeReconnecting(self, ip): for script in self.scripts['before_reconnect']: |