Mercurial > libervia-web
comparison browser_side/radiocol.py @ 300:4f221f34bdc7
browser_side (plugins radiocol, xep-0054): handle upload errors
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 17 Dec 2013 19:37:47 +0100 |
parents | 7a1dc69112b8 |
children | 5943eaa6f422 |
comparison
equal
deleted
inserted
replaced
299:e4f586fc6101 | 300:4f221f34bdc7 |
---|---|
79 def __init__(self, parent): | 79 def __init__(self, parent): |
80 FormPanel.__init__(self) | 80 FormPanel.__init__(self) |
81 self.setEncoding(FormPanel.ENCODING_MULTIPART) | 81 self.setEncoding(FormPanel.ENCODING_MULTIPART) |
82 self.setMethod(FormPanel.METHOD_POST) | 82 self.setMethod(FormPanel.METHOD_POST) |
83 self.setAction("upload_radiocol") | 83 self.setAction("upload_radiocol") |
84 self.timer_on = False | |
84 self._parent = parent | 85 self._parent = parent |
85 vPanel = VerticalPanel() | 86 vPanel = VerticalPanel() |
86 | 87 |
87 types = [('audio/ogg', '*.ogg', 'Ogg Vorbis Audio'), | 88 types = [('audio/ogg', '*.ogg', 'Ogg Vorbis Audio'), |
88 ('video/ogg', '*.ogv', 'Ogg Vorbis Video'), | 89 ('video/ogg', '*.ogv', 'Ogg Vorbis Video'), |
103 | 104 |
104 self.add(vPanel) | 105 self.add(vPanel) |
105 self.addFormHandler(self) | 106 self.addFormHandler(self) |
106 | 107 |
107 def updateStatus(self): | 108 def updateStatus(self): |
109 if self.timer_on: | |
110 return | |
108 # TODO: the status should be different if a song is being played or not | 111 # TODO: the status should be different if a song is being played or not |
109 queue = self._parent.getQueueSize() | 112 queue = self._parent.getQueueSize() |
110 queue_data = self._parent.queue_data | 113 queue_data = self._parent.queue_data |
111 if queue < queue_data[0]: | 114 if queue < queue_data[0]: |
112 left = queue_data[0] - queue | 115 left = queue_data[0] - queue |
136 self.upload_btn.setEnabled(True) | 139 self.upload_btn.setEnabled(True) |
137 | 140 |
138 def setTemporaryStatus(self, text, style): | 141 def setTemporaryStatus(self, text, style): |
139 self.status.setText(text) | 142 self.status.setText(text) |
140 self.status.setStyleName('radiocol_upload_status_%s' % style) | 143 self.status.setStyleName('radiocol_upload_status_%s' % style) |
141 Timer(5000, self.updateStatus) | 144 self.timer_on = True |
145 | |
146 def cb(): | |
147 self.timer_on = False | |
148 self.updateStatus() | |
149 | |
150 Timer(5000, cb) | |
142 | 151 |
143 def onSubmitComplete(self, event): | 152 def onSubmitComplete(self, event): |
144 result = event.getResults() | 153 result = event.getResults() |
145 if result == "OK": | 154 if result == "OK": |
146 # the song can still be rejected (not readable, full queue...) | 155 # the song can still be rejected (not readable, full queue...) |
147 self.setTemporaryStatus('[Your song has been submitted to the radio]', "ok") | 156 self.setTemporaryStatus('[Your song has been submitted to the radio]', "ok") |
148 elif result == "KO": | 157 elif result == "KO": |
149 self.setTemporaryStatus('[Something went wrong during your song upload]', "ko") | 158 self.setTemporaryStatus('[Something went wrong during your song upload]', "ko") |
159 self._parent.radiocolSongRejected("Uploaded file is not Ogg Vorbis song, only Ogg Vorbis songs are acceptable") | |
160 # TODO: would be great to re-use the original Exception class and message | |
161 # but it is lost in the middle of the traceback and encapsulated within | |
162 # a DBusException instance --> extract the data from the traceback? | |
150 else: | 163 else: |
151 Window.alert('Submit error: %s' % result) | 164 Window.alert('Submit error: %s' % result) |
152 self.status.setText('') | 165 self.status.setText('') |
153 | 166 |
154 | 167 |