diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/file_list.py | 1 | ||||
-rwxr-xr-x | module/network/Request.py | 38 | ||||
-rw-r--r-- | module/thread_list.py | 3 |
3 files changed, 23 insertions, 19 deletions
diff --git a/module/file_list.py b/module/file_list.py index 7eaca7c97..4b3577bfc 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -102,7 +102,6 @@ class File_List(object): self.files.insert(index + offset, pyfile) break - index = self.data['order'].index(id) pyfile = self.data['order'].pop(index) self.data['order'].insert(index + offset, pyfile) diff --git a/module/network/Request.py b/module/network/Request.py index 30ffbcd3e..8e3ece456 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -9,6 +9,7 @@ import base64 import cookielib import time import urllib +from urllib2 import URLError, HTTPError import urllib2 from gzip import GzipFile @@ -146,22 +147,27 @@ class Request: if not self.dl: self.dl = True file = open(filename, 'wb') - conn = self.downloader.open(req, post) - if conn.headers.has_key("content-length"): - self.dl_size = int(conn.headers["content-length"]) - else: - self.dl_size = 0 - self.dl_arrived = 0 - self.dl_time = time.time() - for chunk in conn: - if self.abort: raise AbortDownload - self.dl_arrived += len(chunk) - file.write(chunk) - - file.close() - self.dl = False - self.dl_finished = time.time() - return True + try: + conn = self.downloader.open(req, post) + if conn.headers.has_key("content-length"): + self.dl_size = int(conn.headers["content-length"]) + else: + self.dl_size = 0 + self.dl_arrived = 0 + self.dl_time = time.time() + for chunk in conn: + if self.abort: raise AbortDownload + self.dl_arrived += len(chunk) + file.write(chunk) + + file.close() + self.dl = False + self.dl_finished = time.time() + return True + except HTTPError, e: + print e + except URLError, e: + print e def get_speed(self): try: diff --git a/module/thread_list.py b/module/thread_list.py index cf3df9f94..c578ac752 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -63,7 +63,6 @@ class Thread_List(object): if not self.parent.is_dltime() or self.pause or self.reconnecting or not self.list.files: #conditions when threads dont download return None - self.init_reconnect() self.lock.acquire() @@ -105,7 +104,7 @@ class Thread_List(object): self.list.files.insert(0, pyfile) 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['failed_file'], 'a') as f: f.write(pyfile.url + "\n") self.list.remove(pyfile) |