[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r17309: {updater} Stop dropping a byte every time a download fails. also start (updater/trunk/lib/thandy)
Author: nickm
Date: 2008-11-16 21:35:00 -0500 (Sun, 16 Nov 2008)
New Revision: 17309
Modified:
updater/trunk/lib/thandy/download.py
updater/trunk/lib/thandy/util.py
Log:
Stop dropping a byte every time a download fails. also start working on making other exceptions propagete from woder threads.
Modified: updater/trunk/lib/thandy/download.py
===================================================================
--- updater/trunk/lib/thandy/download.py 2008-11-17 02:16:40 UTC (rev 17308)
+++ updater/trunk/lib/thandy/download.py 2008-11-17 02:35:00 UTC (rev 17309)
@@ -40,6 +40,9 @@
for t in self.threads:
t.setDaemon(True)
+ #DOCDOC
+ self._raiseMe = None
+
def start(self):
"""Start all of this download manager's worker threads."""
for t in self.threads:
@@ -80,6 +83,9 @@
self.done.wait()
self.done.release()
+ if self._raiseMe:
+ raise self._raiseMe
+
try:
while True:
item = self.resultQueue.get(block=False)
@@ -233,7 +239,7 @@
gotRange = f_in.info().get("Content-Range")
expectLength = f_in.info().get("Content-Length", "???")
if gotRange:
- if gotRange.startswith("bytes %s-"%(have_length+1)):
+ if gotRange.startswith("bytes %s-"%have_length):
logging.info("Resuming download from %s"%url)
f_out = open(self._tmpPath, 'a')
else:
@@ -344,7 +350,7 @@
is_http = urltype in ["http", "https"]
if have_length is not None and is_http:
- headers['Range'] = "bytes=%s-"%(have_length+1)
+ headers['Range'] = "bytes=%s-"%have_length
req = urllib2.Request(url, headers=headers)
Modified: updater/trunk/lib/thandy/util.py
===================================================================
--- updater/trunk/lib/thandy/util.py 2008-11-17 02:16:40 UTC (rev 17308)
+++ updater/trunk/lib/thandy/util.py 2008-11-17 02:35:00 UTC (rev 17309)
@@ -10,6 +10,11 @@
except ImportError:
import simplejson as json
+try:
+ import _winreg
+except ImportError:
+ _winreg = None
+
import thandy.formats
import thandy.keys
import thandy.master_keys
@@ -100,3 +105,4 @@
return i
return lst[-1][1]
+