comparison browser_side/notification.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 4ba4b099d266
children
comparison
equal deleted inserted replaced
438:582c435dab6b 439:d52f529a6d42
1 from __pyjamas__ import JS, wnd 1 from __pyjamas__ import JS, wnd
2 from sat.core.log import getLogger
3 log = getLogger(__name__)
2 from pyjamas import Window 4 from pyjamas import Window
3 from pyjamas.Timer import Timer 5 from pyjamas.Timer import Timer
4 from browser_side import dialog 6 from browser_side import dialog
5 from sat.core.i18n import _ 7 from sat.core.i18n import _
6 8
58 # FIXME: need to be removed if Chromium behaviour changes 60 # FIXME: need to be removed if Chromium behaviour changes
59 try: 61 try:
60 version_full = [s for s in self.user_agent.split() if "Chrome" in s][0].split('/')[1] 62 version_full = [s for s in self.user_agent.split() if "Chrome" in s][0].split('/')[1]
61 version = int(version_full.split('.')[0]) 63 version = int(version_full.split('.')[0])
62 except (IndexError, ValueError): 64 except (IndexError, ValueError):
63 print "Can't find Chromium version" 65 log.warning("Can't find Chromium version")
64 version = 0 66 version = 0
65 print "Chromium version: %d" % (version,) 67 log.info("Chromium version: %d" % (version,))
66 if version < 22: 68 if version < 22:
67 print "Notification use the old prefixed version or are unmanaged" 69 log.info("Notification use the old prefixed version or are unmanaged")
68 return 70 return
69 if version < 32: 71 if version < 32:
70 dialog.InfoDialog(_("Notifications activation for Chromium"), _('You need to activate notifications manually for your Chromium version.<br/>To activate notifications, click on the favicon on the left of the address bar')).show() 72 dialog.InfoDialog(_("Notifications activation for Chromium"), _('You need to activate notifications manually for your Chromium version.<br/>To activate notifications, click on the favicon on the left of the address bar')).show()
71 return 73 return
72 74
73 print "==> Installing Chromium notifications request workaround <==" 75 log.info("==> Installing Chromium notifications request workaround <==")
74 self._old_click = wnd().onclick 76 self._old_click = wnd().onclick
75 wnd().onclick = self._chromiumWorkaround 77 wnd().onclick = self._chromiumWorkaround
76 78
77 def _chromiumWorkaround(self): 79 def _chromiumWorkaround(self):
78 print "Activating workaround" 80 log.info("Activating workaround")
79 JS(""" 81 JS("""
80 Notification.requestPermission(function(permission){ 82 Notification.requestPermission(function(permission){
81 if (permission !== 'granted') 83 if (permission !== 'granted')
82 return; 84 return;
83 self.enabled = true; //need to use self instead of this 85 self.enabled = true; //need to use self instead of this