Mercurial > libervia-web
comparison src/browser/sat_browser/radiocol.py @ 481:bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 15 Jun 2014 17:52:08 +0200 |
parents | 97c72fe4a5f2 |
children |
comparison
equal
deleted
inserted
replaced
480:50b286866739 | 481:bbdc5357dc00 |
---|---|
20 import pyjd # this is dummy in pyjs | 20 import pyjd # this is dummy in pyjs |
21 from sat.core.log import getLogger | 21 from sat.core.log import getLogger |
22 log = getLogger(__name__) | 22 log = getLogger(__name__) |
23 from sat_frontends.tools.misc import DEFAULT_MUC | 23 from sat_frontends.tools.misc import DEFAULT_MUC |
24 from sat.core.i18n import _ | 24 from sat.core.i18n import _ |
25 from constants import Const as C | |
25 | 26 |
26 from pyjamas.ui.VerticalPanel import VerticalPanel | 27 from pyjamas.ui.VerticalPanel import VerticalPanel |
27 from pyjamas.ui.HorizontalPanel import HorizontalPanel | 28 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
28 from pyjamas.ui.FlexTable import FlexTable | 29 from pyjamas.ui.FlexTable import FlexTable |
29 from pyjamas.ui.FormPanel import FormPanel | 30 from pyjamas.ui.FormPanel import FormPanel |
159 | 160 |
160 Timer(5000, cb) | 161 Timer(5000, cb) |
161 | 162 |
162 def onSubmitComplete(self, event): | 163 def onSubmitComplete(self, event): |
163 result = event.getResults() | 164 result = event.getResults() |
164 if result == "OK": | 165 if result == C.UPLOAD_OK: |
165 # the song can still be rejected (not readable, full queue...) | 166 # the song can still be rejected (not readable, full queue...) |
166 self.setTemporaryStatus('[Your song has been submitted to the radio]', "ok") | 167 self.setTemporaryStatus('[Your song has been submitted to the radio]', "ok") |
167 elif result == "KO": | 168 elif result == C.UPLOAD_KO: |
168 self.setTemporaryStatus('[Something went wrong during your song upload]', "ko") | 169 self.setTemporaryStatus('[Something went wrong during your song upload]', "ko") |
169 self._parent.radiocolSongRejected(_("The uploaded file has been rejected, only Ogg Vorbis and MP3 songs are accepted.")) | 170 self._parent.radiocolSongRejected(_("The uploaded file has been rejected, only Ogg Vorbis and MP3 songs are accepted.")) |
170 # TODO: would be great to re-use the original Exception class and message | 171 # TODO: would be great to re-use the original Exception class and message |
171 # but it is lost in the middle of the traceback and encapsulated within | 172 # but it is lost in the middle of the traceback and encapsulated within |
172 # a DBusException instance --> extract the data from the traceback? | 173 # a DBusException instance --> extract the data from the traceback? |
173 else: | 174 else: |
174 Window.alert('Submit error: %s' % result) | 175 Window.alert(_('Submit error: %s' % result)) |
175 self.status.setText('') | 176 self.status.setText('') |
176 | 177 |
177 | 178 |
178 class Player(Audio): | 179 class Player(Audio): |
179 | 180 |