summaryrefslogtreecommitdiffstats
path: root/download_thread.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-19 14:19:31 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-19 14:19:31 +0200
commit0036345203f37f7f29cc60cbf19b4f355ee8e0ce (patch)
tree74093dc90b9e520bcc43e3409f417668be43c9c9 /download_thread.py
parentfunzt im moment nicht, aber ich arbeite daran (diff)
downloadpyload-0036345203f37f7f29cc60cbf19b4f355ee8e0ce.tar.xz
UploadedTo funktioniert jetzt auch. Wartezeit wird auch berücksichigt.
TODO: Reconnect verwalten, Download Verwaltung -> von einem Plugin nur eine Datei gleichzeitig, Zeit zum Downloaden etc..
Diffstat (limited to 'download_thread.py')
-rw-r--r--download_thread.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/download_thread.py b/download_thread.py
index b90559650..2b6fafdab 100644
--- a/download_thread.py
+++ b/download_thread.py
@@ -27,6 +27,7 @@ class Status(object):
""" Saves all status information
"""
def __init__(self, id):
+ self.type = None
self.status_queue = None
self.id = id
self.total_kb = 0
@@ -35,6 +36,9 @@ class Status(object):
self.expected_time = 0
self.filename = None
self.url = None
+ self.exists = None
+ self.waituntil = None
+ self.want_reconnect = None
def __call__(self, blocks_read, block_size, total_size):
if self.status_queue == None:
@@ -61,6 +65,7 @@ class Download_Thread(threading.Thread):
threading.Thread.__init__(self)
self.shutdown = False
self.parent = parent
+ self.setDaemon(True)
self.start()
def run(self):
@@ -78,11 +83,14 @@ class Download_Thread(threading.Thread):
pyfile.prepareDownload()
if not status.exists:
- return False
-
- while (time() < status.waituntil):
- print "waiting"
- sleep(1)
+ self.shutdown = True
+
+ if status.want_reconnect:
+ print "handle reconnect"
+ self.shutdown = True
+ while (time() < status.waituntil):
+ status.type = "waiting"
+ sleep(1) #eventuell auf genaue zeit warten
#missing wenn datei nicht auf server vorhanden
#if type=="check":
@@ -96,8 +104,8 @@ class Download_Thread(threading.Thread):
# status.type = "waiting"
# print params
# sleep(params+1)
-
+ print "going to download"
status.type = "downloading"
#startet downloader
- urllib.urlretrieve(status.dl, pyfile.download_folder + "/" + status.filename, status)
+ urllib.urlretrieve(status.url, pyfile.download_folder + "/" + status.filename, status)
self.shutdown = True