How to use the somecomfort.client.SessionTimedOut function in somecomfort

To help you get started, we’ve selected a few somecomfort examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kk7ds / somecomfort / somecomfort / client.py View on Github external
def keepalive(self):
        """Makes a keepalive request to avoid session timeout.

        Raises SessionTimedOut if the session has timed out.
        """
        url = self._default_url
        resp = self._session.get(url, timeout=self._timeout)
        if resp.status_code != 200:
            _LOG.info('Session timed out')
            raise SessionTimedOut('Session timed out')
        _LOG.info('Session refreshed')
github kk7ds / somecomfort / somecomfort / client.py View on Github external
def __init__(self, username, password, timeout=30,
                 session=None):
        self._username = username
        self._password = password
        self._session = session or self._get_session()
        self._session.headers['X-Requested-With'] = 'XMLHttpRequest'
        self._timeout = timeout
        self._locations = {}
        self._baseurl = 'https://www.mytotalconnectcomfort.com/portal'
        self._default_url = self._baseurl
        try:
            # Something changed recently, so just always act like we're
            # timed out on startup
            raise SessionTimedOut()
            self.keepalive()
        except SessionTimedOut:
            self._session.cookies.clear()
            self._login()
        self._discover()
github kk7ds / somecomfort / somecomfort / client.py View on Github external
def _retries_login(self):
        try:
            self.keepalive()
        except SessionTimedOut:
            self._login()

        yield