diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/thandy/download.py | 10 | ||||
-rw-r--r-- | lib/thandy/util.py | 6 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/thandy/download.py b/lib/thandy/download.py index 8a9f083..2f98b30 100644 --- a/lib/thandy/download.py +++ b/lib/thandy/download.py @@ -40,6 +40,9 @@ class DownloadManager: 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 @@ class DownloadManager: 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 @@ class DownloadJob: 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 @@ def getConnection(url, useTor, have_length=None): 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) diff --git a/lib/thandy/util.py b/lib/thandy/util.py index c1f1326..00efb59 100644 --- a/lib/thandy/util.py +++ b/lib/thandy/util.py @@ -10,6 +10,11 @@ try: 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 @@ def randChooseWeighted(lst): return i return lst[-1][1] + |