def lazy_login_wrapper(*args, **kwargs): try: return func(*args, **kwargs) except NotLoggedInError: common.debug('Tried to perform an action without being logged in') try: api.login() common.debug('Now that we\'re logged in, let\'s try again') return func(*args, **kwargs) except MissingCredentialsError: # Aborted from user or left an empty field xbmcplugin.endOfDirectory(handle=g.PLUGIN_HANDLE, succeeded=False)
def reset_esn(self, pathitems=None): # pylint: disable=unused-argument """Reset the ESN stored (retrieved from website and manual)""" from resources.lib.database.db_utils import (TABLE_SESSION, TABLE_SETTINGS_MONITOR) if not ui.ask_for_confirmation(common.get_local_string(30217), common.get_local_string(30218)): return # Reset the ESN obtained from website/generated g.LOCAL_DB.set_value('esn', '', TABLE_SESSION) # Reset the custom ESN (manual ESN from settings) g.settings_monitor_suspend(at_first_change=True) g.ADDON.setSetting('esn', '') # Reset the custom ESN (backup of manual ESN from settings, used in settings_monitor.py) g.LOCAL_DB.set_value('custom_esn', '', TABLE_SETTINGS_MONITOR) # Perform a new login to get/generate a new ESN api.login(ask_credentials=False) # Warning after login netflix switch to the main profile! so return to the main screen url = 'plugin://plugin.video.netflix' # Open root page xbmc.executebuiltin('Container.Update({},replace)'.format(url)) # replace=reset history
def lazy_login_wrapper(*args, **kwargs): try: return func(*args, **kwargs) except NotLoggedInError: common.debug('Tried to perform an action without being logged in') if api.login(): common.debug('Now that we\'re logged in, let\'s try again') return func(*args, **kwargs) else: common.debug('Login failed or canceled, abort initial action') xbmcplugin.endOfDirectory(handle=g.PLUGIN_HANDLE, succeeded=False)
def check_valid_credentials(): """Check that credentials are valid otherwise request user credentials""" # This function check only if credentials exist, instead lazy_login # only works in conjunction with nfsession and also performs other checks if not common.check_credentials(): try: if not api.login(): # Wrong login try again return check_valid_credentials() except MissingCredentialsError: # Aborted from user or left an empty field return False return True
def _check_valid_credentials(): """Check that credentials are valid otherwise request user credentials""" # This function check only if credentials exist, instead lazy_login # only works in conjunction with nfsession and also performs other checks if not check_credentials(): from resources.lib.api.exceptions import MissingCredentialsError try: from resources.lib.api.shakti import login if not login(): # Wrong login try again return _check_valid_credentials() except MissingCredentialsError: # Aborted from user or left an empty field return False return True
def lazy_login_wrapper(*args, **kwargs): from resources.lib.api.exceptions import (NotLoggedInError, MissingCredentialsError) try: return func(*args, **kwargs) except NotLoggedInError: debug('Tried to perform an action without being logged in') try: from resources.lib.api.shakti import login if not login(ask_credentials=not check_credentials()): _handle_endofdirectory() raise MissingCredentialsError debug('Now that we\'re logged in, let\'s try again') return func(*args, **kwargs) except MissingCredentialsError: # Aborted from user or left an empty field _handle_endofdirectory() raise