Skip to content

Commit

Permalink
Order imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
perara committed Aug 5, 2022
1 parent 5d96d6f commit c553112
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
11 changes: 8 additions & 3 deletions systemair/saveconnect/auth.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import logging
import time

import httpx
from bs4 import BeautifulSoup

_LOGGER = logging.getLogger(__name__)


class SaveConnectAuth:

def __init__(self, api: "SaveConnect"):
def __init__(self, api):
"""HTTP Client"""
# self._cookie_jar = aiohttp.CookieJar(unsafe=True)
transport = httpx.AsyncHTTPTransport(retries=api.http_retries)
Expand Down Expand Up @@ -61,7 +65,7 @@ async def auth(self, email, password):

return True if self._oidc_token else False

async def refresh_token(self, retry=0):
async def refresh_token(self):
try:

response = await self._http.post(
Expand All @@ -80,7 +84,8 @@ async def refresh_token(self, retry=0):

self._token_expiry = time.time() + self._oidc_token["expires_in"] - (self._oidc_token["expires_in"] * .20)
except httpx.ConnectTimeout:
_LOGGER.info("Recieved connection timeout while refreshing token")
_LOGGER.info("Received connection timeout while refreshing token")

def is_auth(self):
return self._token_expiry < time.time() and len(self._oidc_token) > 0

Expand Down
3 changes: 2 additions & 1 deletion systemair/saveconnect/data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
import typing

from systemair.saveconnect.models import SaveConnectDevice, SaveConnectRegisterItem, update
from systemair.saveconnect.models import (SaveConnectDevice,
SaveConnectRegisterItem, update)
from systemair.saveconnect.register import Register, SaveConnectRegistry

_LOGGER = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions systemair/saveconnect/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from systemair.saveconnect.models import SaveConnectDevice
from systemair.saveconnect.registry import RegisterWrite

from .const import APIRoutes

_LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion systemair/saveconnect/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from typing import Dict

from pydantic import BaseModel, typing, Field
from pydantic import BaseModel, Field, typing


class SaveConnectDeviceUnits(BaseModel):
Expand Down
2 changes: 2 additions & 0 deletions systemair/saveconnect/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,8 +1345,10 @@ class Register:
"242424": "REG_USERMODE_DUMMY_MANUAL"
}
import typing

from pydantic import BaseModel


class SaveConnectRegistry(BaseModel):

IAM_HEARTBEAT: "SaveConnectRegisterItem" = None
Expand Down
2 changes: 1 addition & 1 deletion systemair/saveconnect/systemair.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import typing

from .auth import SaveConnectAuth
from .const import UserModes, Airflow
from .const import Airflow, UserModes
from .data import SaveConnectData
from .graphql import SaveConnectGraphQL
from .models import SaveConnectDevice
Expand Down
4 changes: 2 additions & 2 deletions systemair/saveconnect/websocket.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import socket
import asyncio
import websockets
import logging
import socket

import websockets
from websockets.exceptions import InvalidStatusCode

logger = logging.getLogger(__name__)
Expand Down

0 comments on commit c553112

Please sign in to comment.