Exemplo n.º 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)
Exemplo n.º 2
0
def _check_valid_credentials():
    """Check that credentials are valid otherwise request user credentials"""
    if not check_credentials():
        try:
            from resources.lib.api.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
Exemplo n.º 3
0
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.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
Exemplo n.º 4
0
 def lazy_login_wrapper(*args, **kwargs):
     from resources.lib.api.exceptions import (
         NotLoggedInError, MissingCredentialsError,
         LoginValidateErrorIncorrectPassword)
     try:
         return func(*args, **kwargs)
     except (NotLoggedInError, LoginValidateErrorIncorrectPassword):
         debug('Tried to perform an action without being logged in')
         try:
             from resources.lib.api.api_requests 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
Exemplo n.º 5
0
 def lazy_login_wrapper(*args, **kwargs):
     try:
         # Before call a method, check if the credentials exists
         if not _check_valid_credentials():
             return False
         return func(*args, **kwargs)
     except (NotLoggedInError, LoginValidateError):
         # Exceptions raised by nfsession: "login" / "assert_logged_in" / "website_extract_session_data"
         debug('Tried to perform an action without being logged in')
         try:
             from resources.lib.api.api_requests import login
             if not login(ask_credentials=not check_credentials()):
                 return False
             debug('Account logged in, try executing again {}',
                   func.__name__)
             return func(*args, **kwargs)
         except MissingCredentialsError:
             # Cancelled from user or left an empty field
             return False