def authenticate(self): global auth_local_webserver import socket from oauth2client.file import Storage storage = Storage(self.authFile) credentials = storage.get() if credentials and not credentials.invalid: return credentials if auth_local_webserver: success = False port_number = 0 for port in auth_host_port: port_number = port try: httpd = ClientRedirectServer( (auth_host_name, port), ClientRedirectHandler, ) except socket.error as e: pass else: success = True break auth_local_webserver = success if auth_local_webserver: oauth_callback = 'http://%s:%s/' % (auth_host_name, port_number) else: oauth_callback = 'oob' core.openUrl(self.flow.step1_get_authorize_url(oauth_callback)) code = None if auth_local_webserver: httpd.handle_request() if 'error' in httpd.query_params: self.showError(_('Authentication request was rejected.')) return if 'code' in httpd.query_params: code = httpd.query_params['code'] else: self.showError( _('Failed to find "code" in the query parameters of the redirect.' )) return else: code = self.askVerificationCode() try: credential = self.flow.step2_exchange(code) except Exception as e: self.showError(_('Authentication has failed') + ':\n%s' % e) return storage.put(credential) credential.set_store(storage) return credentials
def authenticate(self): global auth_local_webserver storage = Storage(self.authFile) credentials = storage.get() if credentials and not credentials.invalid: return credentials if auth_local_webserver: success = False port_number = 0 for port in auth_host_port: port_number = port try: httpd = ClientRedirectServer( (auth_host_name, port), ClientRedirectHandler, ) except socket.error as e: pass else: success = True break auth_local_webserver = success if auth_local_webserver: oauth_callback = 'http://%s:%s/' % (auth_host_name, port_number) else: oauth_callback = 'oob' core.openUrl(self.flow.step1_get_authorize_url(oauth_callback)) code = None if auth_local_webserver: httpd.handle_request() if 'error' in httpd.query_params: self.showError('Authentication request was rejected.') return if 'code' in httpd.query_params: code = httpd.query_params['code'] else: self.showError('Failed to find "code" in the query parameters of the redirect.') return else: code = self.askVerificationCode() try: credential = self.flow.step2_exchange(code) except Exception as e: self.showError('Authentication has failed: %s'%e) return storage.put(credential) credential.set_store(storage) return credentials
## skip-taskbar-hint need to restart ro be applied self.updateMenuSize() #self.updateToolbarClock()## FIXME #self.updateTrayClock() self.trayUpdate() ###########################################################################3 #core.COMMAND = sys.argv[0] ## OR __file__ ## ???????? gtk.init_check() clickWebsite = lambda widget, url: core.openUrl(url) try: gtk.link_button_set_uri_hook(clickWebsite) except:## old PyGTK (older than 2.10) pass try: gtk.about_dialog_set_url_hook(clickWebsite) except:## old PyGTK (older than 2.10) pass """ themeDir = join(rootDir, 'themes') theme = 'Dark' # 'Default if theme!=None:
def onConfigChange(self, *a, **kw): ud.BaseCalObj.onConfigChange(self, *a, **kw) #self.set_property('skip-taskbar-hint', not ui.winTaskbar) ## self.set_skip_taskbar_hint ## FIXME ## skip-taskbar-hint need to restart ro be applied #self.updateToolbarClock()## FIXME #self.updateStatusIconClock() self.statusIconUpdate() ###########################################################################3 #core.COMMAND = sys.argv[0] ## OR __file__ ## ???????? gtk.init_check() clickWebsite = lambda widget, url: core.openUrl(url) try: gtk.link_button_set_uri_hook(clickWebsite) except: ## old PyGTK (older than 2.10) pass try: gtk.about_dialog_set_url_hook(clickWebsite) except: ## old PyGTK (older than 2.10) pass for plug in core.allPlugList: if hasattr(plug, 'onCurrentDateChange'): listener.dateChange.add(plug) """ themeDir = join(rootDir, 'themes')