eternalegypt/eternalegypt.py
def autologin(function, timeout=TIMEOUT):
    """Decorator that will try to login and redo an action before failing."""
    @wraps(function)
    async def wrapper(self, *args, **kwargs):
        """Wrap a function with timeout."""
        try:
            async with async_timeout.timeout(timeout):
                return await function(self, *args, **kwargs)
        except (asyncio.TimeoutError, ClientError, Error):
            pass

        _LOGGER.debug("autologin")
        try:
            async with async_timeout.timeout(timeout):
                await self.login()
                return await function(self, *args, **kwargs)
        except (asyncio.TimeoutError, ClientError, Error):
            raise Error(str(function))

    return wrapper
def autologin(function, timeout=TIMEOUT):
    @wraps(function)
    async def wrapper(self, *args, **kwargs):
        """Wrap a function with timeout."""
        try:
            async with async_timeout.timeout(timeout):
                return await function(self, *args, **kwargs)
        except (asyncio.TimeoutError, ClientError, Error):
            pass

        _LOGGER.debug("autologin")
        try:
            async with async_timeout.timeout(timeout):
                await self.login()
                return await function(self, *args, **kwargs)
        except (asyncio.TimeoutError, ClientError, Error):
            raise Error(str(function))

    return wrapper
def autologin ( function , timeout = TIMEOUT ) : @ wraps ( function ) async def wrapper ( self , * args , * * kwargs ) : """Wrap a function with timeout.""" try : async with async_timeout . timeout ( timeout ) : return await function ( self , * args , * * kwargs ) except ( asyncio . TimeoutError , ClientError , Error ) : pass _LOGGER . debug ( "autologin" ) try : async with async_timeout . timeout ( timeout ) : await self . login ( ) return await function ( self , * args , * * kwargs ) except ( asyncio . TimeoutError , ClientError , Error ) : raise Error ( str ( function ) ) return wrapper
Decorator that will try to login and redo an action before failing.
Decorator that will try to login and redo an action before failing .