aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Plugins/SystemPlugins/NFIFlash
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2009-05-16 19:04:44 +0200
committerFelix Domke <tmbinc@elitedvb.net>2009-05-16 19:04:44 +0200
commit34bb54f1a28201b896c06c6b4aedf11a1b25f6d2 (patch)
tree5191729c40d0708d00254740c610bf7a4dff3059 /lib/python/Plugins/SystemPlugins/NFIFlash
parent1bba7d19f64a7a2896bdb54a1c54c585f591cc8c (diff)
parent9f2d37189bea613bb562a4e8b69121572d8efe5f (diff)
downloadenigma2-34bb54f1a28201b896c06c6b4aedf11a1b25f6d2.tar.gz
enigma2-34bb54f1a28201b896c06c6b4aedf11a1b25f6d2.zip
Merge branch 'master' of /home/tmbinc/enigma2-git
Diffstat (limited to 'lib/python/Plugins/SystemPlugins/NFIFlash')
-rw-r--r--lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py52
1 files changed, 1 insertions, 51 deletions
diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py
index c91c8588..6d404cf2 100644
--- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py
+++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py
@@ -16,6 +16,7 @@ from enigma import eConsoleAppContainer, eListbox, gFont, eListboxPythonMultiCon
from os import system, remove
import re
import urllib
+from Tools.Downloader import downloadWithProgress
from twisted.web import client
from twisted.internet import reactor, defer
from twisted.python import failure
@@ -24,57 +25,6 @@ from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier
class UserRequestedCancel(Exception):
pass
-class HTTPProgressDownloader(client.HTTPDownloader):
- def __init__(self, url, outfile, headers=None):
- client.HTTPDownloader.__init__(self, url, outfile, headers=headers, agent="Dreambox .NFI Download Plugin")
- self.status = None
- self.progress_callback = None
- self.deferred = defer.Deferred()
-
- def noPage(self, reason):
- if self.status == "304":
- print reason.getErrorMessage()
- client.HTTPDownloader.page(self, "")
- else:
- client.HTTPDownloader.noPage(self, reason)
-
- def gotHeaders(self, headers):
- if self.status == "200":
- if headers.has_key("content-length"):
- self.totalbytes = int(headers["content-length"][0])
- else:
- self.totalbytes = 0
- self.currentbytes = 0.0
- return client.HTTPDownloader.gotHeaders(self, headers)
-
- def pagePart(self, packet):
- if self.status == "200":
- self.currentbytes += len(packet)
- if self.totalbytes and self.progress_callback:
- self.progress_callback(self.currentbytes, self.totalbytes)
- return client.HTTPDownloader.pagePart(self, packet)
-
- def pageEnd(self):
- return client.HTTPDownloader.pageEnd(self)
-
-class downloadWithProgress:
- def __init__(self, url, outputfile, contextFactory=None, *args, **kwargs):
- scheme, host, port, path = client._parse(url)
- self.factory = HTTPProgressDownloader(url, outputfile, *args, **kwargs)
- self.connection = reactor.connectTCP(host, port, self.factory)
-
- def start(self):
- return self.factory.deferred
-
- def stop(self):
- print "[stop]"
- self.connection.disconnect()
- #self.factory.deferred.errback(failure.Failure(UserRequestedCancel))
-
- def addProgress(self, progress_callback):
- print "[addProgress]"
- self.factory.progress_callback = progress_callback
-
class Feedlist(MenuList):
def __init__(self, list=[], enableWrapAround = False):
MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)