comparison browser_side/radiocol.py @ 439:d52f529a6d42

browser side: use of new log system (first draft): - configuration is hardcoded in libervia.py, it will change in the (hopefuly) near future - log level is DEBUG for the moment, will be changed to INFO when configuration will not be hardcoded anymore - the basic log backend is used, in the future, a console.debug/info/etc should be used instead. A log widget which HTML colors is also an option
author Goffi <goffi@goffi.org>
date Thu, 08 May 2014 17:21:34 +0200
parents 20c508f9b32a
children
comparison
equal deleted inserted replaced
438:582c435dab6b 439:d52f529a6d42
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 import pyjd # this is dummy in pyjs 20 import pyjd # this is dummy in pyjs
21 from sat.core.log import getLogger
22 log = getLogger(__name__)
21 from pyjamas.ui.VerticalPanel import VerticalPanel 23 from pyjamas.ui.VerticalPanel import VerticalPanel
22 from pyjamas.ui.HorizontalPanel import HorizontalPanel 24 from pyjamas.ui.HorizontalPanel import HorizontalPanel
23 from pyjamas.ui.FlexTable import FlexTable 25 from pyjamas.ui.FlexTable import FlexTable
24 from pyjamas.ui.FormPanel import FormPanel 26 from pyjamas.ui.FormPanel import FormPanel
25 from pyjamas.ui.Label import Label 27 from pyjamas.ui.Label import Label
196 self.title = title 198 self.title = title
197 self.artist = artist 199 self.artist = artist
198 self.album = album 200 self.album = album
199 self.played = False 201 self.played = False
200 self.setSrc("radiocol/%s" % html_sanitize(filename)) 202 self.setSrc("radiocol/%s" % html_sanitize(filename))
201 print "preloading %s in %s" % (title, self._id) 203 log.debug("preloading %s in %s" % (title, self._id))
202 204
203 def play(self, play=True): 205 def play(self, play=True):
204 """Play or pause the song 206 """Play or pause the song
205 @param play: set to True to play or to False to pause 207 @param play: set to True to play or to False to pause
206 """ 208 """
289 #we use it to preload the next one 291 #we use it to preload the next one
290 player.preload(timestamp, filename, title, artist, album) 292 player.preload(timestamp, filename, title, artist, album)
291 preloaded = True 293 preloaded = True
292 break 294 break
293 if not preloaded: 295 if not preloaded:
294 print(_("WARNING: Can't preload song, we are getting too many songs to preload, we shouldn't have more than %d at once") % self.queue_data[1]) 296 log.warning("Can't preload song, we are getting too many songs to preload, we shouldn't have more than %d at once" % self.queue_data[1])
295 else: 297 else:
296 self.pushNextSong(title) 298 self.pushNextSong(title)
297 self._parent.printInfo(_('%(user)s uploaded %(artist)s - %(title)s') % {'user': sender, 'artist': artist, 'title': title}) 299 self._parent.printInfo(_('%(user)s uploaded %(artist)s - %(title)s') % {'user': sender, 'artist': artist, 'title': title})
298 300
299 def radiocolPlay(self, filename): 301 def radiocolPlay(self, filename):
305 self.current_player = player 307 self.current_player = player
306 found = True 308 found = True
307 else: 309 else:
308 player.play(False) # in case the previous player was not sync 310 player.play(False) # in case the previous player was not sync
309 if not found: 311 if not found:
310 print("WARNING: Song not found in queue, can't play it. This should not happen") 312 log.error("Song not found in queue, can't play it. This should not happen")
311 313
312 def radiocolNoUpload(self): 314 def radiocolNoUpload(self):
313 self.control_panel.blockUpload() 315 self.control_panel.blockUpload()
314 316
315 def radiocolUploadOk(self): 317 def radiocolUploadOk(self):