diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-28 12:52:56 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-28 12:52:56 +0200 |
commit | c9eb7081bbd4cedf9a6574c39ceb0cfde1083113 (patch) | |
tree | 7c3e26941ccf347c6a1571b155cc8ef1cc2d685c /module | |
parent | fexed little bug (diff) | |
download | pyload-c9eb7081bbd4cedf9a6574c39ceb0cfde1083113.tar.xz |
clean up some code, new config parser, basic time shedule
Diffstat (limited to 'module')
-rw-r--r-- | module/Py_Load_File.py | 3 | ||||
-rw-r--r-- | module/download_thread.py | 4 | ||||
-rw-r--r-- | module/thread_list.py | 27 |
3 files changed, 16 insertions, 18 deletions
diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py index ecfded6fd..97479384c 100644 --- a/module/Py_Load_File.py +++ b/module/Py_Load_File.py @@ -1,6 +1,7 @@ -from download_thread import Status import re +from download_thread import Status + class PyLoadFile: """ represents the url or file """ diff --git a/module/download_thread.py b/module/download_thread.py index 9147af923..f8786c810 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -20,7 +20,6 @@ import threading from time import time, sleep -from copy import copy class Status(object): """ Saves all status information @@ -92,8 +91,7 @@ class Download_Thread(threading.Thread): sleep(1) self.parent.remove_thread(self) - def download(self, py_load_file): - pyfile = py_load_file + def download(self, pyfile): status = pyfile.status pyfile.prepareDownload() diff --git a/module/thread_list.py b/module/thread_list.py index 4cd1f1978..a206c19c4 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -18,13 +18,12 @@ # ### #python -import time -import urllib2 import re import subprocess -from Queue import Queue +import time +import urllib2 from threading import Lock -#my + from download_thread import Download_Thread class Thread_List(object): @@ -33,12 +32,11 @@ class Thread_List(object): self.threads = [] self.max_threads = 3 self.py_load_files = [] # files in queque - self.download_queue = Queue() - #self.status_queue = Queue() - self.f_relation = [0,0] + self.f_relation = [0, 0] self.lock = Lock() self.py_downloading = [] # files downloading - self.occ_plugins = [] #occupied plugins + self.occ_plugins = [] #occupied plugins + self.pause = False def create_thread(self): """ creates thread for Py_Load_File and append thread to self.threads @@ -66,7 +64,10 @@ class Thread_List(object): def get_job(self): # return job if suitable, otherwise send thread idle self.lock.acquire() - + + if self.pause: + return None + pyfile = None for i in range(len(self.py_load_files)): if not self.py_load_files[i].modul.__name__ in self.occ_plugins: @@ -77,7 +78,7 @@ class Thread_List(object): self.py_downloading.append(pyfile) if not pyfile.plugin.multi_dl: self.occ_plugins.append(pyfile.modul.__name__) - self.parent.logger.info('start downloading ' + pyfile.url ) + self.parent.logger.info('start downloading ' + pyfile.url) self.lock.release() return pyfile @@ -90,12 +91,11 @@ class Thread_List(object): self.occ_plugins.remove(pyfile.modul.__name__) self.py_downloading.remove(pyfile) - self.parent.logger.info('finished downloading ' + pyfile.url + ' @'+str(pyfile.status.get_speed())+'kb/s') + self.parent.logger.info('finished downloading ' + pyfile.url + ' @' + str(pyfile.status.get_speed()) + 'kb/s') - if pyfile.plugin.plugin_config['type'] == "container": + if pyfile.plugin.props['type'] == "container": self.parent.extend_links(pyfile.plugin.links) - #remove from list, logging etc self.lock.release() return True @@ -111,7 +111,6 @@ class Thread_List(object): def append_py_load_file(self, py_load_file): py_load_file.id = len(self.py_load_files) self.py_load_files.append(py_load_file) - self.download_queue.put(py_load_file) self.f_relation[1] += 1 self.select_thread() |