diff options
author | mkaay <mkaay@mkaay.de> | 2010-12-23 11:28:03 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-12-23 11:28:03 +0100 |
commit | a4ba4ba12aff34c967f958576db40806656c3de8 (patch) | |
tree | 57a26d6559279fa4ed9c28fadfa31f4d36a7eceb /module/network/HTTPDownload.py | |
parent | new download backend integrated so far, downloading works, but still big todo... (diff) | |
download | pyload-a4ba4ba12aff34c967f958576db40806656c3de8.tar.xz |
fixed eta and progress, ready for first test
Diffstat (limited to 'module/network/HTTPDownload.py')
-rw-r--r-- | module/network/HTTPDownload.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py index e38e1ba1b..1baf0ccad 100644 --- a/module/network/HTTPDownload.py +++ b/module/network/HTTPDownload.py @@ -167,6 +167,9 @@ class HTTPDownload(object): def speed(self): return self.getSpeed() + def calcProgress(self, p): + self.deferred.progress("percent", 100-int((self.size - self.arrived)/float(self.size)*100)) + def _copyChunks(self): fo = open(self.filename, "wb") for i in range(self.info.getCount()): @@ -219,6 +222,7 @@ class HTTPDownload(object): self.chunks.append(chunk) d = chunk.download() dg.addDeferred(d) + d.addProgress("percent", self.calcProgress) if not self.info.loaded: size = chunk.size @@ -266,6 +270,7 @@ class HTTPDownload(object): break self.chunks.append(chunk) dg.addDeferred(d) + d.addProgress("percent", self.calcProgress) if not self.info.loaded: self.info.addChunk("%s.chunk%d" % (self.filename, i), chunk.range, chunk.getEncoding()) @@ -274,7 +279,8 @@ class HTTPDownload(object): dg.addCallback(self._copyChunks) if not len(self.chunks): dg.callback() - return WrappedHTTPDeferred(self, dg) + dg.addErrback(self.deferred.error) + return WrappedHTTPDeferred(self, self.deferred) else: raise Exception("no chunks") |