From 7579e0750c7bd81c916012e2842c8a96ad8fa414 Mon Sep 17 00:00:00 2001 From: mkaay Date: Sun, 22 Nov 2009 15:04:30 +0100 Subject: secure xmlrpc --- module/thread_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index d4f2dac97..da13afba6 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -60,7 +60,7 @@ class Thread_List(object): def get_job(self): """return job if suitable, otherwise send thread idle""" - if not self.parent.is_dltime() or self.pause or self.reconnecting or not self.list.files: #conditions when threads dont download + if not self.parent.is_time_download() or self.pause or self.reconnecting or not self.list.files: #conditions when threads dont download return None self.init_reconnect() -- cgit v1.2.3 From 523e2857c47cdef1da6b43523bcf7871ed9e1d63 Mon Sep 17 00:00:00 2001 From: mkaay Date: Thu, 26 Nov 2009 22:05:11 +0100 Subject: complete new file_list, cleaned up --- module/thread_list.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index da13afba6..aa50a654f 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -60,7 +60,7 @@ class Thread_List(object): def get_job(self): """return job if suitable, otherwise send thread idle""" - if not self.parent.is_time_download() or self.pause or self.reconnecting or not self.list.files: #conditions when threads dont download + if not self.parent.is_time_download() or self.pause or self.reconnecting or self.list.queueEmpty(): #conditions when threads dont download return None self.init_reconnect() @@ -68,15 +68,16 @@ class Thread_List(object): self.lock.acquire() pyfile = None - for i in range(len(self.list.files)): - if not self.list.files[i].modul.__name__ in self.occ_plugins: - pyfile = self.list.files.pop(i) + for f in self.list.getDownloadList(): + if not f.modul.__name__ in self.occ_plugins: + pyfile = f break if pyfile: self.py_downloading.append(pyfile) if not pyfile.plugin.multi_dl: self.occ_plugins.append(pyfile.modul.__name__) + pyfile.active = True self.parent.logger.info('Download starts: ' + pyfile.url) self.lock.release() @@ -89,6 +90,8 @@ class Thread_List(object): if not pyfile.plugin.multi_dl: self.occ_plugins.remove(pyfile.modul.__name__) + + pyfile.active = False if pyfile.plugin.req.curl and not pyfile.status == "reconnected": try: @@ -101,25 +104,23 @@ class Thread_List(object): if pyfile.status.type == "finished": self.parent.logger.info('Download finished: ' + pyfile.url + ' @' + str(pyfile.status.get_speed()) + 'kb/s') - self.list.remove(pyfile) - if pyfile.plugin.props['type'] == "container": - self.list.extend(pyfile.plugin.links) - + self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.id) + for link in pyfile.plugin.links: + id = self.list.collector.addLink(link) + pyfile.packager.pullOutPackage(pyfile.package.id) + pyfile.packager.addFileToPackage(pyfile.package.id, pyfile.collector.popFile(id)) - elif pyfile.status.type == "reconnected":#put it back in queque + elif pyfile.status.type == "reconnected": pyfile.plugin.req.init_curl() - self.list.files.insert(0, pyfile) elif pyfile.status.type == "failed": self.parent.logger.warning("Download failed: " + pyfile.url+ " | " + pyfile.status.error) with open(self.parent.config['general']['failed_file'], 'a') as f: f.write(pyfile.url + "\n") - self.list.remove(pyfile) elif pyfile.status.type == "aborted": self.parent.logger.info("Download aborted: " + pyfile.url) - self.list.remove(pyfile) self.list.save() -- cgit v1.2.3 From f7563727e1ccb8d764904806cb9e262ba555f824 Mon Sep 17 00:00:00 2001 From: spoob Date: Mon, 30 Nov 2009 15:18:04 +0100 Subject: Cleaned XMLRPC in Core --- module/thread_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index aa50a654f..fc886e4b4 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -60,7 +60,7 @@ class Thread_List(object): def get_job(self): """return job if suitable, otherwise send thread idle""" - if not self.parent.is_time_download() or self.pause or self.reconnecting or self.list.queueEmpty(): #conditions when threads dont download + if not self.parent.server_methods.is_time_download() or self.pause or self.reconnecting or self.list.queueEmpty(): #conditions when threads dont download return None self.init_reconnect() -- cgit v1.2.3 From f98a9eea978ccf56d41f4ce355f2b514fc9e4af1 Mon Sep 17 00:00:00 2001 From: spoob Date: Thu, 3 Dec 2009 23:33:46 +0100 Subject: Convert read_url_list to new Plugin --- module/thread_list.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index fc886e4b4..55f237544 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -78,7 +78,10 @@ class Thread_List(object): if not pyfile.plugin.multi_dl: self.occ_plugins.append(pyfile.modul.__name__) pyfile.active = True - self.parent.logger.info('Download starts: ' + pyfile.url) + if pyfile.plugin.props['type'] == "container": + self.parent.logger.info('Get links from: ' + pyfile.url) + else: + self.parent.logger.info('Download starts: ' + pyfile.url) self.lock.release() return pyfile @@ -102,14 +105,27 @@ class Thread_List(object): self.py_downloading.remove(pyfile) if pyfile.status.type == "finished": - self.parent.logger.info('Download finished: ' + pyfile.url + ' @' + str(pyfile.status.get_speed()) + 'kb/s') - if pyfile.plugin.props['type'] == "container": - self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.id) + #works(!) but adds many packs to queue + newLinks = 0 + newPackager = self.list.packager.addNewPackage(pyfile.status.filename) for link in pyfile.plugin.links: - id = self.list.collector.addLink(link) - pyfile.packager.pullOutPackage(pyfile.package.id) - pyfile.packager.addFileToPackage(pyfile.package.id, pyfile.collector.popFile(id)) + newFile = self.list.collector.addLink(link) + self.list.packager.addFileToPackage(newPackager, self.list.collector.popFile(newFile)) + newLinks += 1 + self.list.packager.pushPackage2Queue(newPackager) + + if newLinks: + self.parent.logger.info("Parsed link from %s: %i" % (pyfile.status.filename, newLinks)) + else: + self.parent.logger.info("No links in %s" % pyfile.status.filename) + #~ self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.id) + #~ for link in pyfile.plugin.links: + #~ id = self.list.collector.addLink(link) + #~ pyfile.packager.pullOutPackage(pyfile.package.id) + #~ pyfile.packager.addFileToPackage(pyfile.package.id, pyfile.collector.popFile(id)) + else: + self.parent.logger.info("Download finished: %s" % pyfile.url) elif pyfile.status.type == "reconnected": pyfile.plugin.req.init_curl() -- cgit v1.2.3 From 78f061eed59e084f001f8a0cd9c5b585f6fc0ce0 Mon Sep 17 00:00:00 2001 From: mkaay Date: Fri, 4 Dec 2009 20:01:17 +0100 Subject: fixes, minimal gui changes --- module/thread_list.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 55f237544..3c69121c2 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -107,14 +107,16 @@ class Thread_List(object): if pyfile.status.type == "finished": if pyfile.plugin.props['type'] == "container": #works(!) but adds many packs to queue + self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.data["id"]) newLinks = 0 - newPackager = self.list.packager.addNewPackage(pyfile.status.filename) - for link in pyfile.plugin.links: - newFile = self.list.collector.addLink(link) - self.list.packager.addFileToPackage(newPackager, self.list.collector.popFile(newFile)) - newLinks += 1 - self.list.packager.pushPackage2Queue(newPackager) - + if pyfile.plugin.links: + newPackager = self.list.packager.addNewPackage(pyfile.status.filename) + for link in pyfile.plugin.links: + newFile = self.list.collector.addLink(link) + self.list.packager.addFileToPackage(newPackager, self.list.collector.popFile(newFile)) + newLinks += 1 + self.list.packager.pushPackage2Queue(newPackager) + if newLinks: self.parent.logger.info("Parsed link from %s: %i" % (pyfile.status.filename, newLinks)) else: -- cgit v1.2.3 From 2c7203032324820c122b1e7b77604212391f75f9 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 10 Dec 2009 15:44:37 +0100 Subject: cleaned some code, pyLoad Script Support (closed #16) --- module/thread_list.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 3c69121c2..2faec1581 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -18,12 +18,12 @@ # ### from __future__ import with_statement +from os.path import exists import re import subprocess +from threading import RLock import time import urllib2 -from os.path import exists -from threading import RLock from download_thread import Download_Thread @@ -75,6 +75,7 @@ class Thread_List(object): if pyfile: self.py_downloading.append(pyfile) + self.scripts_download_preparing(pyfile.modul.__name__, pyfile.url) if not pyfile.plugin.multi_dl: self.occ_plugins.append(pyfile.modul.__name__) pyfile.active = True @@ -133,7 +134,7 @@ class Thread_List(object): pyfile.plugin.req.init_curl() elif pyfile.status.type == "failed": - self.parent.logger.warning("Download failed: " + pyfile.url+ " | " + pyfile.status.error) + self.parent.logger.warning("Download failed: " + pyfile.url + " | " + pyfile.status.error) with open(self.parent.config['general']['failed_file'], 'a') as f: f.write(pyfile.url + "\n") @@ -142,6 +143,8 @@ class Thread_List(object): self.list.save() + self.scripts_download_finished(pyfile.modul.__name__, pyfile.url, pyfile.status.filename, pyfile.download_folder) + self.lock.release() return True @@ -186,7 +189,7 @@ class Thread_List(object): return False def reconnect(self): - reconn = subprocess.Popen(self.parent.config['general']['reconnect_method']) + reconn = subprocess.Popen(self.parent.config['general']['reconnect_method'], stdout=subprocess.PIPE) reconn.wait() time.sleep(1) ip = "" @@ -197,3 +200,18 @@ class Thread_List(object): ip = "" time.sleep(1) self.parent.logger.info("Reconnected, new IP: " + ip) + + + def scripts_download_preparing(self, pluginname, url): + for script in self.parent.scripts['download_preparing']: + out = subprocess.Popen([script, pluginname, url], stdout=subprocess.PIPE) + out.wait() + + def scripts_download_finished(self, pluginname, url, filename, location): + map(lambda script: subprocess.Popen([script, pluginname, url, filename, location], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) + + def scripts_package_finished(self, name, location): #@TODO Implement! + map(lambda script: subprocess.Popen([script, name, location], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) + + def scripts_reconnected(self, ip): + map(lambda script: subprocess.Popen([script, ip], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) -- cgit v1.2.3 From 6fdfdd1f85b0e2d95bdc8955459c0465833831d6 Mon Sep 17 00:00:00 2001 From: spoob Date: Thu, 10 Dec 2009 21:38:03 +0100 Subject: create automatic script folders --- module/thread_list.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 2faec1581..8c1695f38 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -199,13 +199,14 @@ class Thread_List(object): except: ip = "" time.sleep(1) + scripts_reconnected(ip) self.parent.logger.info("Reconnected, new IP: " + ip) def scripts_download_preparing(self, pluginname, url): - for script in self.parent.scripts['download_preparing']: - out = subprocess.Popen([script, pluginname, url], stdout=subprocess.PIPE) - out.wait() + for script in self.parent.scripts['download_preparing']: + out = subprocess.Popen([script, pluginname, url], stdout=subprocess.PIPE) + out.wait() def scripts_download_finished(self, pluginname, url, filename, location): map(lambda script: subprocess.Popen([script, pluginname, url, filename, location], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) -- cgit v1.2.3 From 3937e57e93be49142b5b6347aa80a390cacd474a Mon Sep 17 00:00:00 2001 From: spoob Date: Tue, 15 Dec 2009 23:14:12 +0100 Subject: Fixed web/init, download script --- module/thread_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 8c1695f38..c486ad8ee 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -143,7 +143,7 @@ class Thread_List(object): self.list.save() - self.scripts_download_finished(pyfile.modul.__name__, pyfile.url, pyfile.status.filename, pyfile.download_folder) + self.scripts_download_finished(pyfile.modul.__name__, pyfile.url, pyfile.status.filename, pyfile.folder) self.lock.release() return True -- cgit v1.2.3 From 70cd6a9f822308a416fefb051c4bbb83e6fd37e4 Mon Sep 17 00:00:00 2001 From: mkaay Date: Thu, 17 Dec 2009 22:56:56 +0100 Subject: create only one links.txt package --- module/thread_list.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index c486ad8ee..1020f9ce1 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -107,16 +107,14 @@ class Thread_List(object): if pyfile.status.type == "finished": if pyfile.plugin.props['type'] == "container": - #works(!) but adds many packs to queue - self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.data["id"]) newLinks = 0 if pyfile.plugin.links: - newPackager = self.list.packager.addNewPackage(pyfile.status.filename) for link in pyfile.plugin.links: newFile = self.list.collector.addLink(link) - self.list.packager.addFileToPackage(newPackager, self.list.collector.popFile(newFile)) + self.list.packager.addFileToPackage(pyfile.package.data["id"], self.list.collector.popFile(newFile)) newLinks += 1 - self.list.packager.pushPackage2Queue(newPackager) + self.list.packager.pushPackage2Queue(pyfile.package.data["id"]) + self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.data["id"]) if newLinks: self.parent.logger.info("Parsed link from %s: %i" % (pyfile.status.filename, newLinks)) -- cgit v1.2.3 From adcc953b4dd2dce1f91bd7cd11105e9f0653f704 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 19 Dec 2009 15:13:10 +0100 Subject: fixed reconnect --- module/thread_list.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 1020f9ce1..52d06aae4 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -110,6 +110,7 @@ class Thread_List(object): newLinks = 0 if pyfile.plugin.links: for link in pyfile.plugin.links: + print link newFile = self.list.collector.addLink(link) self.list.packager.addFileToPackage(pyfile.package.data["id"], self.list.collector.popFile(newFile)) newLinks += 1 -- cgit v1.2.3 From c521e6445bc8e6b91440813b90d1fdedd76c9721 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 19 Dec 2009 15:25:50 +0100 Subject: real reconnect fix ;-) --- module/thread_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 52d06aae4..6a42898be 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -149,7 +149,7 @@ class Thread_List(object): def init_reconnect(self): """initialise a reonnect""" - if not self.parent.config['general']['use_reconnect'] or self.reconnecting or not self.parent.is_reconnect_time(): + if not self.parent.config['general']['use_reconnect'] or self.reconnecting or not self.parent.server_methods.is_time_reconnect(): return False if not exists(self.parent.config['general']['reconnect_method']): -- cgit v1.2.3 From f7f83692039997e1988cc6fae53676856668444b Mon Sep 17 00:00:00 2001 From: spoob Date: Sat, 19 Dec 2009 19:07:17 +0100 Subject: Fixed Netload, no Premium --- module/thread_list.py | 1 - 1 file changed, 1 deletion(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 6a42898be..d78a9b95c 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -110,7 +110,6 @@ class Thread_List(object): newLinks = 0 if pyfile.plugin.links: for link in pyfile.plugin.links: - print link newFile = self.list.collector.addLink(link) self.list.packager.addFileToPackage(pyfile.package.data["id"], self.list.collector.popFile(newFile)) newLinks += 1 -- cgit v1.2.3 From 5ee3579572b60bb8f9e6475a517d69462b0cfe29 Mon Sep 17 00:00:00 2001 From: mkaay Date: Wed, 23 Dec 2009 21:04:06 +0100 Subject: download speed limit --- module/thread_list.py | 93 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 4 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index d78a9b95c..9cdb5fc8f 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -21,7 +21,7 @@ from __future__ import with_statement from os.path import exists import re import subprocess -from threading import RLock +from threading import RLock, Thread import time import urllib2 @@ -40,6 +40,7 @@ class Thread_List(object): self.reconnecting = False self.select_thread() + self.speedManager = self.SpeedManager(self) def create_thread(self): """ creates thread for Py_Load_File and append thread to self.threads @@ -207,10 +208,94 @@ class Thread_List(object): out.wait() def scripts_download_finished(self, pluginname, url, filename, location): - map(lambda script: subprocess.Popen([script, pluginname, url, filename, location], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) + map(lambda script: subprocess.Popen([script, pluginname, url, filename, location], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) def scripts_package_finished(self, name, location): #@TODO Implement! - map(lambda script: subprocess.Popen([script, name, location], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) + map(lambda script: subprocess.Popen([script, name, location], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) def scripts_reconnected(self, ip): - map(lambda script: subprocess.Popen([script, ip], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) + map(lambda script: subprocess.Popen([script, ip], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) + + class SpeedManager(Thread): + def __init__(self, parent): + Thread.__init__(self) + self.parent = parent + self.running = True + self.lastSlowCheck = 0.0 + + stat = {} + stat["slow_downloads"] = None + stat["each_speed"] = None + stat["each_speed_optimized"] = None + self.stat = stat + + self.slowCheckInterval = 60 + self.slowCheckTestTime = 25 + + self.logger = self.parent.parent.logger + self.start() + + def run(self): + while self.running: + time.sleep(1) + self.manageSpeed() + + def getMaxSpeed(self): + return self.parent.parent.getMaxSpeed() + + def manageSpeed(self): + maxSpeed = self.getMaxSpeed() + if maxSpeed <= 0: + for thread in self.parent.py_downloading: + thread.plugin.req.speedLimitActive = False + return + threads = self.parent.py_downloading + threadCount = len(threads) + if threadCount <= 0: + return + eachSpeed = maxSpeed/threadCount + + currentOverallSpeed = 0 + restSpeed = maxSpeed - currentOverallSpeed + speeds = [] + for thread in threads: + currentOverallSpeed += thread.plugin.req.dl_speed + speeds.append((thread.plugin.req.dl_speed, thread.plugin.req.averageSpeed, thread)) + thread.plugin.req.speedLimitActive = True + + if currentOverallSpeed+50 < maxSpeed: + for thread in self.parent.py_downloading: + thread.plugin.req.speedLimitActive = False + return + + print "-----" + + slowCount = 0 + slowSpeed = 0 + if self.lastSlowCheck + self.slowCheckInterval + self.slowCheckTestTime < time.time(): + self.lastSlowCheck = time.time() + if self.lastSlowCheck + self.slowCheckInterval < time.time() < self.lastSlowCheck + self.slowCheckInterval + self.slowCheckTestTime: + for speed in speeds: + speed[2].plugin.req.isSlow = False + else: + for speed in speeds: + if speed[0] <= eachSpeed-7: + if speed[1] < eachSpeed-15: + if speed[2].plugin.req.dl_time > 0 and speed[2].plugin.req.dl_time+30 < time.time(): + speed[2].plugin.req.isSlow = True + if not speed[1]-5 < speed[2].plugin.req.maxSpeed/1024 < speed[1]+5: + speed[2].plugin.req.maxSpeed = (speed[1]+10)*1024 + if speed[2].plugin.req.isSlow: + slowCount += 1 + slowSpeed += speed[2].plugin.req.maxSpeed/1024 + + stat["slow_downloads"] = slowCount + stat["each_speed"] = eachSpeed + eachSpeed = (maxSpeed - slowSpeed) / (threadCount - slowCount) + stat["each_speed_optimized"] = eachSpeed + for speed in speeds: + if speed[2].plugin.req.isSlow: + continue + speed[2].plugin.req.maxSpeed = eachSpeed*1024 + print "max", speed[2].plugin.req.maxSpeed, "current", speed[2].plugin.req.dl_speed + -- cgit v1.2.3 From ea04c11ce1fb52895449a56e862eff5448ea456a Mon Sep 17 00:00:00 2001 From: mkaay Date: Thu, 24 Dec 2009 01:28:08 +0100 Subject: downloads are now aborted correctly, gui: remove downloads, new icons --- module/thread_list.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 9cdb5fc8f..966157b91 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -267,8 +267,6 @@ class Thread_List(object): for thread in self.parent.py_downloading: thread.plugin.req.speedLimitActive = False return - - print "-----" slowCount = 0 slowSpeed = 0 -- cgit v1.2.3 From 5c7e9f0f1325523347a52869cebbf03463550bca Mon Sep 17 00:00:00 2001 From: mkaay Date: Thu, 24 Dec 2009 01:41:13 +0100 Subject: clean shutdown --- module/thread_list.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 966157b91..fc4160a6d 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -216,6 +216,10 @@ class Thread_List(object): def scripts_reconnected(self, ip): map(lambda script: subprocess.Popen([script, ip], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) + def stopAllDownloads(self): + for pyfile in self.py_downloading: + pyfile.plugin.req.abort = True + class SpeedManager(Thread): def __init__(self, parent): Thread.__init__(self) -- cgit v1.2.3 From 8e87787753b2e049917a5491727d285b1c5a7095 Mon Sep 17 00:00:00 2001 From: mkaay Date: Sun, 27 Dec 2009 00:20:21 +0100 Subject: closes #13 --- module/thread_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index fc4160a6d..719849585 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -188,7 +188,7 @@ class Thread_List(object): return False def reconnect(self): - reconn = subprocess.Popen(self.parent.config['general']['reconnect_method'], stdout=subprocess.PIPE) + reconn = subprocess.Popen(self.parent.config['general']['reconnect_method'])#, stdout=subprocess.PIPE) reconn.wait() time.sleep(1) ip = "" -- cgit v1.2.3 From 48588a0d05492e46126776c3e7023397b9ad0b90 Mon Sep 17 00:00:00 2001 From: spoob Date: Sun, 27 Dec 2009 02:40:56 +0100 Subject: Fixed reconnect loop (easy doing) --- module/thread_list.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 719849585..ad0d0c8fb 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -188,17 +188,18 @@ class Thread_List(object): return False def reconnect(self): + self.parent.logger.info("Start reconnect") reconn = subprocess.Popen(self.parent.config['general']['reconnect_method'])#, stdout=subprocess.PIPE) reconn.wait() time.sleep(1) ip = "" - while ip == "": #solange versuch bis neue ip ausgelesen + while ip == "": try: ip = re.match(".*Current IP Address: (.*).*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1) #versuchen neue ip aus zu lesen except: ip = "" time.sleep(1) - scripts_reconnected(ip) + self.scripts_reconnected(ip) self.parent.logger.info("Reconnected, new IP: " + ip) @@ -300,4 +301,3 @@ class Thread_List(object): continue speed[2].plugin.req.maxSpeed = eachSpeed*1024 print "max", speed[2].plugin.req.maxSpeed, "current", speed[2].plugin.req.dl_speed - -- cgit v1.2.3 From 7c28259f92c2b3c608583ff128a5ae4134d4c48f Mon Sep 17 00:00:00 2001 From: mkaay Date: Wed, 30 Dec 2009 17:33:14 +0100 Subject: moved captcha stuff, extended serienjunkies, some other stuff --- module/thread_list.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index ad0d0c8fb..d3eb4d203 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -110,15 +110,26 @@ class Thread_List(object): if pyfile.plugin.props['type'] == "container": newLinks = 0 if pyfile.plugin.links: - for link in pyfile.plugin.links: - newFile = self.list.collector.addLink(link) - self.list.packager.addFileToPackage(pyfile.package.data["id"], self.list.collector.popFile(newFile)) - newLinks += 1 - self.list.packager.pushPackage2Queue(pyfile.package.data["id"]) + if isinstance(pyfile.plugin.links, dict): + packmap = {} + for packname in pyfile.plugin.links.keys(): + packmap[packname] = self.list.packager.addNewPackage(packname) + for packname, links in pyfile.plugin.links.items(): + pid = packmap[packname] + for link in links: + newFile = self.list.collector.addLink(link) + self.list.packager.addFileToPackage(pid, self.list.collector.popFile(newFile)) + newLinks += 1 + else: + for link in pyfile.plugin.links: + newFile = self.list.collector.addLink(link) + self.list.packager.addFileToPackage(pyfile.package.data["id"], self.list.collector.popFile(newFile)) + newLinks += 1 + #self.list.packager.pushPackage2Queue(pyfile.package.data["id"]) self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.data["id"]) if newLinks: - self.parent.logger.info("Parsed link from %s: %i" % (pyfile.status.filename, newLinks)) + self.parent.logger.info("Parsed links from %s: %i" % (pyfile.status.filename, newLinks)) else: self.parent.logger.info("No links in %s" % pyfile.status.filename) #~ self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.id) -- cgit v1.2.3 From e9dc8ea08452c1555e28f4ac1970b96315ec4376 Mon Sep 17 00:00:00 2001 From: spoob Date: Sun, 3 Jan 2010 21:12:02 +0100 Subject: Cleaned Reconnect XML Config --- module/thread_list.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index d3eb4d203..5d0bcf53a 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -160,12 +160,12 @@ class Thread_List(object): def init_reconnect(self): """initialise a reonnect""" - if not self.parent.config['general']['use_reconnect'] or self.reconnecting or not self.parent.server_methods.is_time_reconnect(): + if not self.parent.config['reconnect']['activated'] or self.reconnecting or not self.parent.server_methods.is_time_reconnect(): return False - if not exists(self.parent.config['general']['reconnect_method']): - self.parent.logger.info(self.parent.config['general']['reconnect_method'] + " not found") - self.parent.config['general']['use_reconnect'] = False + if not exists(self.parent.config['reconnect']['method']): + self.parent.logger.info(self.parent.config['reconnect']['method'] + " not found") + self.parent.config['reconnect']['activated'] = False return False self.lock.acquire() @@ -200,7 +200,7 @@ class Thread_List(object): def reconnect(self): self.parent.logger.info("Start reconnect") - reconn = subprocess.Popen(self.parent.config['general']['reconnect_method'])#, stdout=subprocess.PIPE) + reconn = subprocess.Popen(self.parent.config['activated']['method'])#, stdout=subprocess.PIPE) reconn.wait() time.sleep(1) ip = "" -- cgit v1.2.3 From 89acc0ff595f73956572c8892ccb860c06fba33a Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 4 Jan 2010 20:35:26 +0100 Subject: added hook system --- module/thread_list.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 5d0bcf53a..55b21093f 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -76,7 +76,7 @@ class Thread_List(object): if pyfile: self.py_downloading.append(pyfile) - self.scripts_download_preparing(pyfile.modul.__name__, pyfile.url) + self.parent.hookManager.downloadStarts(pyfile) if not pyfile.plugin.multi_dl: self.occ_plugins.append(pyfile.modul.__name__) pyfile.active = True @@ -153,7 +153,7 @@ class Thread_List(object): self.list.save() - self.scripts_download_finished(pyfile.modul.__name__, pyfile.url, pyfile.status.filename, pyfile.folder) + self.parent.hookManager.downloadFinished(pyfile) self.lock.release() return True @@ -200,6 +200,8 @@ class Thread_List(object): def reconnect(self): self.parent.logger.info("Start reconnect") + ip = re.match(".*Current IP Address: (.*).*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1) + self.parent.hookManager.beforeReconnecting(ip) reconn = subprocess.Popen(self.parent.config['activated']['method'])#, stdout=subprocess.PIPE) reconn.wait() time.sleep(1) @@ -210,23 +212,8 @@ class Thread_List(object): except: ip = "" time.sleep(1) - self.scripts_reconnected(ip) + self.parent.hookManager.afterReconnecting(ip) self.parent.logger.info("Reconnected, new IP: " + ip) - - - def scripts_download_preparing(self, pluginname, url): - for script in self.parent.scripts['download_preparing']: - out = subprocess.Popen([script, pluginname, url], stdout=subprocess.PIPE) - out.wait() - - def scripts_download_finished(self, pluginname, url, filename, location): - map(lambda script: subprocess.Popen([script, pluginname, url, filename, location], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) - - def scripts_package_finished(self, name, location): #@TODO Implement! - map(lambda script: subprocess.Popen([script, name, location], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) - - def scripts_reconnected(self, ip): - map(lambda script: subprocess.Popen([script, ip], stdout=subprocess.PIPE), self.parent.scripts['download_finished']) def stopAllDownloads(self): for pyfile in self.py_downloading: -- cgit v1.2.3 From 8d842efb12ee7db88505e3078b626855e55aa4bf Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 17 Jan 2010 18:31:52 +0100 Subject: some fixes, closed #62 ?? --- module/thread_list.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 55b21093f..e4952587c 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -201,7 +201,7 @@ class Thread_List(object): def reconnect(self): self.parent.logger.info("Start reconnect") ip = re.match(".*Current IP Address: (.*).*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1) - self.parent.hookManager.beforeReconnecting(ip) + #self.parent.hookManager.beforeReconnecting(ip) reconn = subprocess.Popen(self.parent.config['activated']['method'])#, stdout=subprocess.PIPE) reconn.wait() time.sleep(1) @@ -212,10 +212,11 @@ class Thread_List(object): except: ip = "" time.sleep(1) - self.parent.hookManager.afterReconnecting(ip) + #self.parent.hookManager.afterReconnecting(ip) self.parent.logger.info("Reconnected, new IP: " + ip) def stopAllDownloads(self): + self.pause = True for pyfile in self.py_downloading: pyfile.plugin.req.abort = True -- cgit v1.2.3 From b7ba3d89e802cc5e0ff3725bde72bf24f5f5c786 Mon Sep 17 00:00:00 2001 From: spoob Date: Sun, 17 Jan 2010 22:19:57 +0100 Subject: Fixed Reconnect --- module/thread_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index e4952587c..c8580fece 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -202,7 +202,7 @@ class Thread_List(object): self.parent.logger.info("Start reconnect") ip = re.match(".*Current IP Address: (.*).*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1) #self.parent.hookManager.beforeReconnecting(ip) - reconn = subprocess.Popen(self.parent.config['activated']['method'])#, stdout=subprocess.PIPE) + reconn = subprocess.Popen(self.parent.config['reconnect']['method'])#, stdout=subprocess.PIPE) reconn.wait() time.sleep(1) ip = "" -- cgit v1.2.3 From f0914124436b8f66d296ef0d3d0e0f289f5a1aa6 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 22 Jan 2010 19:21:59 +0100 Subject: some final tweaks --- module/thread_list.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index c8580fece..9211c7c2e 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -40,7 +40,8 @@ class Thread_List(object): self.reconnecting = False self.select_thread() - self.speedManager = self.SpeedManager(self) + if self.parent.config['general']['download_speed_limit'] != 0: + self.speedManager = self.SpeedManager(self) def create_thread(self): """ creates thread for Py_Load_File and append thread to self.threads @@ -69,12 +70,10 @@ class Thread_List(object): self.lock.acquire() pyfile = None - for f in self.list.getDownloadList(): - if not f.modul.__name__ in self.occ_plugins: - pyfile = f - break + pyfiles = self.list.getDownloadList(self.occ_plugins) - if pyfile: + if pyfiles: + pyfile = pyfiles[0] self.py_downloading.append(pyfile) self.parent.hookManager.downloadStarts(pyfile) if not pyfile.plugin.multi_dl: -- cgit v1.2.3 From 769f156ea822d4520620727dc1317224a02bdaaa Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 26 Jan 2010 21:23:16 +0100 Subject: extended script support --- module/thread_list.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 9211c7c2e..1a66bf6f5 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -200,7 +200,7 @@ class Thread_List(object): def reconnect(self): self.parent.logger.info("Start reconnect") ip = re.match(".*Current IP Address: (.*).*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1) - #self.parent.hookManager.beforeReconnecting(ip) + self.parent.hookManager.beforeReconnecting(ip) reconn = subprocess.Popen(self.parent.config['reconnect']['method'])#, stdout=subprocess.PIPE) reconn.wait() time.sleep(1) @@ -211,7 +211,7 @@ class Thread_List(object): except: ip = "" time.sleep(1) - #self.parent.hookManager.afterReconnecting(ip) + self.parent.hookManager.afterReconnecting(ip) self.parent.logger.info("Reconnected, new IP: " + ip) def stopAllDownloads(self): -- cgit v1.2.3