diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-06-21 18:16:06 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-06-21 18:16:06 +0200 |
commit | 9a4f077714993bacb4418e7c5b4cb85f5d1601d1 (patch) | |
tree | 86e6951c572f3d1602872c6eb654d79a8e0dce99 | |
parent | fixed no url return bug (diff) | |
download | pyload-9a4f077714993bacb4418e7c5b4cb85f5d1601d1.tar.xz |
plugin system changings
-rw-r--r-- | Plugins/Plugin.py | 19 | ||||
-rw-r--r-- | module/Py_Load_File.py | 10 | ||||
-rw-r--r-- | module/download_thread.py | 33 | ||||
-rw-r--r-- | module/thread_list.py | 2 |
4 files changed, 40 insertions, 24 deletions
diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py index ba3ee29b3..2f13d3c43 100644 --- a/Plugins/Plugin.py +++ b/Plugins/Plugin.py @@ -43,6 +43,25 @@ class Plugin(): self.want_reconnect = False self.multi_dl = True self.ocr = None #captcha reader instance + + def prepare(self, thread): + pyfile = self.parent + + self.want_reconnect = False + + pyfile.status.exists = self.file_exists() + + if not pyfile.status.exists: + raise Exception, "The file was not found on the server." + + pyfile.status.filename = self.get_file_name() + + pyfile.status.waituntil = self.time_plus_wait + pyfile.status.url = self.get_file_url() + pyfile.status.want_reconnect = self.want_reconnect + + thread.wait(self.parent) + def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py index 2bc6d4965..570e605cd 100644 --- a/module/Py_Load_File.py +++ b/module/Py_Load_File.py @@ -28,16 +28,10 @@ class PyLoadFile: return "Plugin" - def prepareDownload(self): + def init_download(self): if self.parent.config['useproxy']: self.plugin.req.add_proxy(self.parent.config['proxyprotocol'], self.parent.config['proxyadress']) - self.plugin.want_reconnect = False + #@todo: check dependicies, ocr etc - self.status.exists = self.plugin.file_exists() - if self.status.exists: - self.status.filename = self.plugin.get_file_name() - self.status.waituntil = self.plugin.time_plus_wait - self.status.url = self.plugin.get_file_url() - self.status.want_reconnect = self.plugin.want_reconnect diff --git a/module/download_thread.py b/module/download_thread.py index 378ae8f79..ce353d6f6 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -35,6 +35,7 @@ class Status(object): self.exists = False self.waituntil = 0 self.want_reconnect = False + self.error = "" def get_ETA(self): return self.pyfile.plugin.req.get_ETA() @@ -68,6 +69,7 @@ class Download_Thread(threading.Thread): except Exception, e: traceback.print_exc() self.loadedPyFile.status.type = "failed" + self.loadedPyFile.status.error = e.message finally: self.parent.job_finished(self.loadedPyFile) sleep(0.5) @@ -77,25 +79,14 @@ class Download_Thread(threading.Thread): def download(self, pyfile): status = pyfile.status - pyfile.prepareDownload() + + pyfile.init_download() + + pyfile.plugin.prepare(self) - if not status.exists: - raise "FileDontExists", "The file was not found on the server." #i know its deprecated, who cares^^ - - status.type = "waiting" - - while (time() < status.waituntil): - if self.parent.init_reconnect() or self.parent.reconnecting: - status.type = "reconnected" - status.want_reconnect = False - return False - sleep(1) - if status.url == "": status.url = pyfile.plugin.get_file_url() - status.want_reconnect = False - status.type = "downloading" pyfile.plugin.proceed(status.url, pyfile.download_folder + "/" + status.filename) @@ -105,3 +96,15 @@ class Download_Thread(threading.Thread): #startet downloader #urllib.urlretrieve(status.url, pyfile.download_folder + "/" + status.filename, status) #self.shutdown = True + + def wait(self, pyfile): + pyfile.status.type = "waiting" + while (time() < pyfile.status.waituntil): + if self.parent.init_reconnect() or self.parent.reconnecting: + pyfile.status.type = "reconnected" + pyfile.status.want_reconnect = False + return False + sleep(1) + pyfile.status.want_reconnect = False + return True + diff --git a/module/thread_list.py b/module/thread_list.py index 54a17e318..63f20c6f5 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -107,7 +107,7 @@ class Thread_List(object): self.list.files.insert(0, pyfile) if pyfile.status.type == "failed": - self.parent.logger.warning("Download failed: " + pyfile.url) + self.parent.logger.warning("Download failed: " + pyfile.url+" | "+ pyfile.status.error) with open(self.parent.config['failed_file'], 'a') as f: f.write(pyfile.url + "\n") |