diff options
author | mkaay <mkaay@mkaay.de> | 2009-12-26 20:18:11 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2009-12-26 20:18:11 +0100 |
commit | 504b313112be6a82d6eee418ae059646ecfc4b30 (patch) | |
tree | 88a8ee96d788bd4b3fd7c97775e85787c3709e8a | |
parent | clean shutdown (diff) | |
download | pyload-504b313112be6a82d6eee418ae059646ecfc4b30.tar.xz |
fixed ddl-music, cleaned up, new status (starting), some more fixes
-rw-r--r-- | module/download_thread.py | 1 | ||||
-rw-r--r-- | module/gui/Queue.py | 15 | ||||
-rw-r--r-- | module/gui/connector.py | 54 | ||||
-rwxr-xr-x | module/network/Request.py | 21 | ||||
-rw-r--r-- | module/plugins/DDLMusicOrg.py | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | pyLoadCore.py | 2 | ||||
-rwxr-xr-x | pyLoadGui.py | 5 |
7 files changed, 82 insertions, 22 deletions
diff --git a/module/download_thread.py b/module/download_thread.py index 401d6f943..be6ff6bf0 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -117,6 +117,7 @@ class Download_Thread(threading.Thread): def download(self, pyfile): status = pyfile.status + status.type = "starting" pyfile.init_download() diff --git a/module/gui/Queue.py b/module/gui/Queue.py index 35e1163b9..f542c9a6b 100644 --- a/module/gui/Queue.py +++ b/module/gui/Queue.py @@ -198,10 +198,10 @@ class Queue(QThread): count = len(children) speed_sum = 0 all_waiting = True + running = False for child in children: val = 0 data = child.getData() - running = False if data["downloading"]: if not data["status_type"] == "waiting": all_waiting = False @@ -239,7 +239,7 @@ class Queue(QThread): item = QTreeWidgetItem() parent.insertChild(pos, item) speed = self.queue.getSpeed(newChild) - if speed == None: + if speed == None or newChild.getData()["status_type"] == "starting": status = newChild.getData()["status_type"] else: status = "%s (%s KB/s)" % (newChild.getData()["status_type"], speed) @@ -269,12 +269,23 @@ class Queue(QThread): def clear(self, ids): clear = False + children = {} for file in self.getChildren(): if not file.getData()["id"] in ids: clear = True break + try: + children[file.getData()["id"]] + clear = True + except: + children[file.getData()["id"]] = True + if not clear: return + ppos = self.queue.queue.index(self) + parent = self.queue.view.topLevelItem(ppos) + parent.takeChildren() + self.children = [] self.queue.queue = [] self.queue.view.emit(SIGNAL("clear")) diff --git a/module/gui/connector.py b/module/gui/connector.py index 4d3af0d61..4ac635200 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -35,6 +35,8 @@ class connector(QThread): self.running = True self.proxy = None self.addr = None + self.errorQueue = [] + self.connect(self, SIGNAL("proxy_error"), self._proxyError) def setAddr(self, addr): """ @@ -52,6 +54,7 @@ class connector(QThread): self.connectProxy(self.addr) while self.running: sleep(1) + self.getError() def stop(self): """ @@ -68,6 +71,21 @@ class connector(QThread): if not server_version == SERVER_VERSION: self.emit(SIGNAL("error_box"), "server is version %s client accepts version %s" % (server_version, SERVER_VERSION)) + def _proxyError(self, func): + """ + formats proxy error msg + """ + msg = "proxy error in '%s'" % (func,) + self.errorQueue.append(msg) + + def getError(self): + self.mutex.lock() + if len(self.errorQueue) > 0: + err = self.errorQueue.pop() + print err + self.emit(SIGNAL("error_box"), err) + self.mutex.unlock() + def getLinkCollector(self): """ grab links from collector and return the ids @@ -75,6 +93,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.get_collector_files() + except: + self.emit(SIGNAL("proxy_error"), "getLinkCollector") finally: self.mutex.unlock() @@ -85,6 +105,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.get_collector_packages() + except: + self.emit(SIGNAL("proxy_error"), "getPackageCollector") finally: self.mutex.unlock() @@ -95,6 +117,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.get_file_info(id) + except: + self.emit(SIGNAL("proxy_error"), "getLinkInfo") finally: self.mutex.unlock() @@ -105,6 +129,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.get_package_data(id) + except: + self.emit(SIGNAL("proxy_error"), "getPackageInfo") finally: self.mutex.unlock() @@ -115,6 +141,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.get_queue() + except: + self.emit(SIGNAL("proxy_error"), "getPackageQueue") finally: self.mutex.unlock() @@ -125,6 +153,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.get_package_files(id) + except: + self.emit(SIGNAL("proxy_error"), "getPackageFiles") finally: self.mutex.unlock() @@ -135,6 +165,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.status_downloads() + except: + self.emit(SIGNAL("proxy_error"), "getDownloadQueue") finally: self.mutex.unlock() @@ -145,6 +177,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.status_server() + except: + self.emit(SIGNAL("proxy_error"), "getServerStatus") finally: self.mutex.unlock() @@ -155,6 +189,8 @@ class connector(QThread): self.mutex.lock() try: self.proxy.add_urls(links) + except: + self.emit(SIGNAL("proxy_error"), "addURLs") finally: self.mutex.unlock() @@ -165,6 +201,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.toggle_pause() + except: + self.emit(SIGNAL("proxy_error"), "togglePause") finally: self.mutex.unlock() @@ -178,6 +216,8 @@ class connector(QThread): self.proxy.pause_server() else: self.proxy.unpause_server() + except: + self.emit(SIGNAL("proxy_error"), "setPause") finally: self.mutex.unlock() @@ -188,6 +228,8 @@ class connector(QThread): self.mutex.lock() try: return self.proxy.new_package(name) + except: + self.emit(SIGNAL("proxy_error"), "newPackage") finally: self.mutex.unlock() @@ -198,6 +240,8 @@ class connector(QThread): self.mutex.lock() try: self.proxy.move_file_2_package(fileid, packid) + except: + self.emit(SIGNAL("proxy_error"), "addFileToPackage") finally: self.mutex.unlock() @@ -208,6 +252,8 @@ class connector(QThread): self.mutex.lock() try: self.proxy.push_package_2_queue(packid) + except: + self.emit(SIGNAL("proxy_error"), "pushPackageToQueue") finally: self.mutex.unlock() @@ -218,6 +264,8 @@ class connector(QThread): self.mutex.lock() try: self.proxy.restart_package(packid) + except: + self.emit(SIGNAL("proxy_error"), "restartPackage") finally: self.mutex.unlock() @@ -228,6 +276,8 @@ class connector(QThread): self.mutex.lock() try: self.proxy.restart_file(fileid) + except: + self.emit(SIGNAL("proxy_error"), "restartFile") finally: self.mutex.unlock() @@ -238,6 +288,8 @@ class connector(QThread): self.mutex.lock() try: self.proxy.del_packages([packid,]) + except: + self.emit(SIGNAL("proxy_error"), "removePackage") finally: self.mutex.unlock() @@ -248,5 +300,7 @@ class connector(QThread): self.mutex.lock() try: self.proxy.del_links([fileid,]) + except: + self.emit(SIGNAL("proxy_error"), "removeFile") finally: self.mutex.unlock() diff --git a/module/network/Request.py b/module/network/Request.py index 651553a0f..c6d6f0901 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -144,7 +144,8 @@ class Request: if cookies: self.curl_enable_cookies() - if post: self.pycurl.setopt(pycurl.POSTFIELDS, post) + if post: + self.pycurl.setopt(pycurl.POSTFIELDS, post) if ref and self.lastURL is not None: self.pycurl.setopt(pycurl.REFERER, self.lastURL) @@ -158,7 +159,7 @@ class Request: return self.header self.pycurl.perform() - + self.lastEffectiveURL = self.pycurl.getinfo(pycurl.EFFECTIVE_URL) self.lastURL = url header = self.get_header() @@ -262,12 +263,12 @@ class Request: self.init_curl() self.pycurl.setopt(pycurl.URL, url) - #self.pycurl.setopt(pycurl.WRITEDATA, fp) if cookies: self.curl_enable_cookies() - if post: self.pycurl.setopt(pycurl.POSTFIELDS, post) + if post: + self.pycurl.setopt(pycurl.POSTFIELDS, post) if self.auth: self.add_auth(self.user, self.pw) @@ -279,7 +280,7 @@ class Request: self.dl_time = time.time() self.dl = True - self.chunkSize = 0 # only for loop to start + self.chunkSize = 0 self.chunkRead = 0 self.subStartTime = 0 self.maxChunkSize = 0 @@ -322,16 +323,6 @@ class Request: code, msg = e if not code == 23: raise Exception, e - #~ if "..." in file_name: - #~ download_folder = dirname(file_name) + sep - #~ headers = self.get_header() - #~ file_name_search = re.search('filename=(?P<quote>\")?(.+)(?(quote)\")', headers) - #~ if file_name_search: - #~ file_name = file_name_search.group(2) - #~ if "?=" in file_name[-3:]: - #~ file_name = file_name.replace("=?UTF-8?B?", "").replace("?=", "==") - #~ file_name = b64decode(file_name) - #~ file_name = download_folder + sep + file_name self.fp.close() diff --git a/module/plugins/DDLMusicOrg.py b/module/plugins/DDLMusicOrg.py index e34e6fbde..c927d261c 100644 --- a/module/plugins/DDLMusicOrg.py +++ b/module/plugins/DDLMusicOrg.py @@ -21,6 +21,7 @@ class DDLMusicOrg(Plugin): self.props = props self.parent = parent self.html = None + self.multi_dl = False def download_html(self): url = self.parent.url @@ -29,7 +30,8 @@ class DDLMusicOrg(Plugin): def file_exists(self): """ returns True or False """ - self.download_html() + if not self.html: + self.download_html() if re.search(r"Wer dies nicht rechnen kann", self.html) != None: return True return False @@ -48,7 +50,7 @@ class DDLMusicOrg(Plugin): else: solve = int(math.group(1)) - int(math.group(3)) sleep(3) - htmlwithlink = self.req.load("http://ddl-music.org%s" % posturl, cookies=True, post={"calc0":solve, "send0":"Send", "id":id, "linknr":linknr}) + htmlwithlink = self.req.load("http://ddl-music.org%s" % posturl, cookies=True, post={"calc%s" % linknr:solve, "send%s" % linknr:"Send", "id":id, "linknr":linknr}) m = re.search(r"<form id=\"ff\" action=\"(.*?)\" method=\"post\">", htmlwithlink) if m: self.links = [m.group(1)] diff --git a/pyLoadCore.py b/pyLoadCore.py index c5bf7ed0a..7cf83389e 100644..100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -522,6 +522,6 @@ if __name__ == "__main__": pyload_core.start()
except KeyboardInterrupt: pyload_core.shutdown()
- pyload_core.logger.info("killed pyLoad by Terminal")
+ pyload_core.logger.info("killed pyLoad from Terminal")
exit()
diff --git a/pyLoadGui.py b/pyLoadGui.py index d5fb02bc0..5e13dd080 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -135,7 +135,8 @@ class main(QObject): """ display a nice error box """ - QMessageBox(QMessageBox.Warning, "Error", msg) + msgb = QMessageBox(QMessageBox.Warning, "Error", msg) + msgb.exec_() def initPackageCollector(self): """ @@ -326,7 +327,7 @@ class main(QObject): data = self.connData data["password"] = pw if not data["type"] == "remote": - coreparser = XMLParser("module/config/core.xml") + coreparser = XMLParser("module/config/core.xml", "module/config/core_default.xml") sections = coreparser.parseNode(coreparser.root, "dict") conf = coreparser.parseNode(sections["remote"], "dict") ssl = coreparser.parseNode(sections["ssl"], "dict") |