From d44888ca5ab15913db944d1b1646df8f103c4ba6 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 26 May 2009 00:04:33 +0200 Subject: improved plugins --- module/download_thread.py | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'module/download_thread.py') diff --git a/module/download_thread.py b/module/download_thread.py index 31d449472..f103b2271 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -83,7 +83,13 @@ class Download_Thread(threading.Thread): if self.parent.py_load_files: self.loadedPyFile = self.parent.get_job() if self.loadedPyFile: - self.download(self.loadedPyFile) + try: + self.download(self.loadedPyFile) + except Exception, e: + print "Error:", e + #catch up all error here + finally: + self.parent.job_finished(self.loadedPyFile) sleep(0.5) if self.shutdown: sleep(1) @@ -94,26 +100,25 @@ class Download_Thread(threading.Thread): status = pyfile.status pyfile.prepareDownload() - if status.exists: - - if status.want_reconnect: - print "handle reconnect" - - while (time() < status.waituntil): - status.type = "waiting" - sleep(1) #eventuell auf genaue zeit warten + if not status.exists: + raise "FileDontExists" #i know its deprecated, who cares^^ - - status.type = "downloading" - print status.url , status.filename + + if status.want_reconnect: + print "handle reconnect" - try: - pyfile.plugin.req.download(status.url, pyfile.download_folder + "/" + status.filename) - status.type = "finished" - except: - status.type = "failed" + while (time() < status.waituntil): + status.type = "waiting" + sleep(1) #eventuell auf genaue zeit warten - self.parent.job_finished(pyfile) + try: + status.type = "downloading" + print status.url , status.filename + + pyfile.plugin.req.download(status.url, pyfile.download_folder + "/" + status.filename) + status.type = "finished" + except: + status.type = "failed" #startet downloader #urllib.urlretrieve(status.url, pyfile.download_folder + "/" + status.filename, status) -- cgit v1.2.3