Exemple #1
0
 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
     # Open root page
     common.container_update(G.BASE_URL, True)
Exemple #2
0
def _check_valid_credentials():
    """Check that credentials are valid otherwise request user credentials"""
    if not check_credentials():
        try:
            from resources.lib.utils.api_requests 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):
     if _check_valid_credentials():
         try:
             return func(*args, **kwargs)
         except (NotLoggedInError, LoginValidateError):
             # Exceptions raised by nfsession: "login" / "assert_logged_in" / "website_extract_session_data"
             LOG.debug('Tried to perform an action without being logged in')
             try:
                 from resources.lib.utils.api_requests import login
                 if login(ask_credentials=not check_credentials()):
                     LOG.debug('Account logged in, try executing again {}',
                               func.__name__)
                     return func(*args, **kwargs)
             except MissingCredentialsError:
                 # Cancelled from user or left an empty field
                 pass
     return False
Exemple #4
0
 def lazy_login_wrapper(*args, **kwargs):
     if _check_valid_credentials():
         try:
             return func(*args, **kwargs)
         except NotLoggedInError:
             # Exception raised by nfsession: "login" / "assert_logged_in" / "website_extract_session_data"
             LOG.debug('Tried to perform an action without being logged in')
             try:
                 from resources.lib.utils.api_requests import login
                 if login(ask_credentials=not check_credentials()):
                     LOG.debug('Account logged in, try executing again {}', func.__name__)
                     return func(*args, **kwargs)
             except MissingCredentialsError:
                 # Cancelled from user or left an empty field
                 pass
             except LoginError as exc:
                 # Login not valid
                 from resources.lib.kodi.ui import show_ok_dialog
                 show_ok_dialog(get_local_string(30008), str(exc))
     return False