Please wait
-
-
Was genau ist die Frage?
Du möchtest ganz sicher kein time.sleep verwenden!
-
Beim Herunterladen der Datei möchte ich Informationen anzeigen, bitte warten.
-
zunaechst solltest du das downloaden programmieren, dann ergibt sich die anzeige. das ganze muss asynchron erfolgen, also kein while true oder time.sleep moeglich.
-
digis
Schau mal wie ich das hier gelöst habe, downloadwithprogress wäre eine Lösung für dein Problem. -
Sehr lange Quellcode,das ist bisschen kompliziert.
Ich bin Anfänger, konnte ich ein Beispiel bekommen??
-
Egal was ich mache das wird einfach nicht,
ich kapiere das nicht.
Code
Alles anzeigendef test(self): file = '/tmp/python-2.7.18.amd64.msi' file_url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi ' try: self["info"].setText(_('bitte warten..')) dowenload = urllib.urlretrieve(file_url, file) if os.path.exists(file): self["text"].setText(_("successful")) else: self["text"].setText('error 1') except: self["text"].setText('error 2')
-
du machst es ja auch falsch. dhwz hat dir gesagt, du sollst dir downloadWithProgress anschauen und nicht, urlretrieve.
Codedef test(self): self.url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' self.local = '/tmp/python-2.7.18.amd64.msi' self.download = downloadWithProgress(self.url, self.local) self.download.addProgress(self.http_progress) self.download.start().addCallback(self.http_finished).addErrback(self.http_failed)
das ist doch viel einfacher. Und damit hast du auch gleich ein sauberes Error Handling dabei. Die entsprechenden callback-functions musst du natürlich auch übernehmen (http_progress, http_finished, http_failed).
-
hier noch ein anderes beispiel:
https://github.com/dream-alpha…/blob/master/src/Cover.py
getCover wird aufgerufen, um das cover herunterzuladen und getCoverCallback wird dann automatisch (asynchron) aufgerufen, wenn der download fertig ist.
-
-
Na, das ist mal eine exakte Fehlermeldung
-
Das liegt an der Funktion http_progress,
sorry für meine Fehlerbeschreibung.
Habe für alle Linien # gesetzt,
print "test"
das war mein Test
-
Keine Ahnung. Du wirst schon wissen, was du machst. Merkst du eigentlich, dass es extrem schwierig ist, dir auch nur ein bisschen zu helfen, wenn du 0 Infos lieferst?
-
Python
Alles anzeigenclass test(Screen): skin = """ <screen position="center,center" size="640,150" backgroundColor="#54242424" title="TEST" > <widget name="header" position="5,10" size="10,50" font="Regular;40" backgroundColor="#54242424"/> <widget name="info" position="5,60" size="10,130" font="Regular;24" backgroundColor="#54242424"/> <widget name="progress" position="5,39" size="10,24" backgroundColor="#54242424"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session self.downloader = None self['header'] = Label(_('test')) self['info'] = Label(_('test')) self['progress'] = ProgressBar() self['progress'].setRange((0, 100)) self['progress'].setValue(0) self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'cancel': self.abort, 'red': self.abort, 'ok': self.startDownload, 'green': self.startDownload}, -1) def startDownload(self): from Tools.Downloader import downloadWithProgress self.url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' self.local = '/tmp/python-2.7.18.amd64.msi' self['header'].setText(_('Downloading')) self['info'].setText(self.local) self.downloader = downloadWithProgress(self.url, self.local) self.downloader.addProgress(self.downloadProgress) self.downloader.addEnd(self.downloadEnd) self.downloader.addError(self.downloadError) self.downloader.start() def downloadError(self): self.downloader.stop() self.session.openWithCallback(self.abort, MessageBox, _('Error during downloading image\n%s\n%s') % (self.local), type=MessageBox.TYPE_ERROR) def downloadProgress(self): self['progress'].setValue(int(100 * current / total)) def downloadEnd(self): self.downloader.stop() def abort(self): if self.downloader: self.downloader.stop() self.close()
Vieles habe ich gemacht aber komme ich trotzdem nicht vorwärts,
irgendwo ist kleine Fehler ??
-
wie ist die fehlermeldung und wie sehen die imports aus?
-
Code
0xb4b6268c(sp=0xbeec1bc0) <PyEval_EvalFrameEx+24024> Traceback (most recent call last): File "/usr/lib/enigma2/python/enigma.py", line 8610, in __call__ return ret(*args, **kwargs) File "/usr/lib/enigma2/python/Components/ActionMap.py", line 70, in action res = act() File "/usr/lib/enigma2/python/Plugins/Extensions/test/test.py", line 57, in startDownload self.downloader.addEnd(self.downloadEnd) ------- AttributeError: downloadWithProgress instance has no attribute 'addEnd'
-
-
Python
Alles anzeigenclass test(Screen): skin = """ <screen position="center,center" size="640,280" backgroundColor="#54242424" title="TEST" > <widget name="header" position="5,5" size="350,60" font="Regular;40" backgroundColor="#54242424"/> <widget name="info" position="5,70" size="350,60" font="Regular;24" backgroundColor="#54242424"/> <widget name="progress" position="5,140" size="350,60" backgroundColor="#54242424"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session #self.DownloadFinished = DownloadFinished #self.DownloadFailed = DownloadFailed self['header'] = Label(_('header')) self['info'] = Label(_('info')) self['progress'] = Label() self['progress'].hide() self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'cancel': self.abort, 'red': self.abort, 'ok': self.startDownload, 'green': self.startDownload}, -1) def startDownload(self): self.url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' self.file = 'python-2.7.18.amd64.msi' self.local = '/tmp/'+self.file self['header'].setText(_('Downloading')) self['info'].setText(self.file) self.download = downloadWithProgress(self.url, self.local) self.download.addProgress(self.downloadProgress) self.download.start().addCallback(self.DownloadFinished).addErrback(self.DownloadFailed) def DownloadFailed(self): self.downloader.stop() self.session.openWithCallback(self.abort, MessageBox, _('Error during downloading image\n%s\n%s') % (self.local), type=MessageBox.TYPE_ERROR) def downloadProgress(self, recvbytes, totalbytes): self['progress'].setValue(int(100 * recvbytes / totalbytes)) def DownloadFinished(self): self.close() def abort(self): self.close()
Keine Fortschrittsanzeige(Fortschrittsbalken),
Datei herunterladen funktioniert nicht.
Kein crash.log
-
-
Python
Alles anzeigenclass MDscripts(Screen): skin = """ <screen position="center,center" size="950,550" title="TEST" > <widget name="progress" position="10,10" size="620,10" backgroundColor="#54242424" /> <widget name="header" position="10,25" size="620,390" font="Regular;40" backgroundColor="#54242424" valign="center" halign="center" transparent="1"/> <widget name="info" position="10,400" size="920,60" font="Regular;40" backgroundColor="#54242424" transparent="1" zPosition="5"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session self['header'] = Label(_('1.header')) self['info'] = Label(_('2.info')) #self['progress'] = Label(_(' ')) self['progress'] = Label() self['progress'].hide() self.progress = 0 self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'cancel': self.abort, 'red': self.abort, 'ok': self.startDownload, 'green': self.startDownload}, -1) def startDownload(self): agent = 'Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0' self.url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' self.file = 'python-2.7.18.amd64.msi' self.local = '/tmp/'+self.file self['header'].setText(_('Downloading')) self['info'].setText(self.file) self.download = downloadWithProgress(self.url, self.local, agent=agent) self.download.addProgress(self.downloadProgress) self.download.start().addCallback(self.DownloadFinished).addErrback(self.DownloadFailed) def DownloadFailed(self): self.download.stop() self.session.openWithCallback(self.abort, MessageBox, _('Error during downloading image\n%s\n%s') % (self.local), type=MessageBox.TYPE_ERROR) def downloadProgress(self, recvbytes, totalbytes): self.progress = int(100 * recvbytes/float(totalbytes)) def DownloadFinished(self): self.download.stop() self['header'].setText(_('erfolgreich'))
Datei herunterladen funktioniert aber,
jetzt fehlt nur noch Fortschrittsbalken und DownloadFinished Mitteilung.
Kein crash.log