fyta-cli 0.2__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fyta_cli-0.2 → fyta_cli-0.2.1}/PKG-INFO +1 -1
- {fyta_cli-0.2 → fyta_cli-0.2.1}/pyproject.toml +1 -1
- {fyta_cli-0.2 → fyta_cli-0.2.1}/src/fyta_cli/fyta_client.py +3 -5
- {fyta_cli-0.2 → fyta_cli-0.2.1}/src/fyta_cli/fyta_connector.py +4 -4
- {fyta_cli-0.2 → fyta_cli-0.2.1}/LICENSE +0 -0
- {fyta_cli-0.2 → fyta_cli-0.2.1}/README.md +0 -0
- {fyta_cli-0.2 → fyta_cli-0.2.1}/src/fyta_cli/__init__.py +0 -0
- {fyta_cli-0.2 → fyta_cli-0.2.1}/src/fyta_cli/fyta_exceptions.py +0 -0
|
@@ -12,7 +12,7 @@ import asyncio
|
|
|
12
12
|
from aiohttp import BasicAuth, ClientSession
|
|
13
13
|
from dataclasses import dataclass, field
|
|
14
14
|
|
|
15
|
-
from fyta_exceptions import (
|
|
15
|
+
from .fyta_exceptions import (
|
|
16
16
|
FytaError,
|
|
17
17
|
FytaConnectionError,
|
|
18
18
|
FytaAuthentificationError,
|
|
@@ -75,14 +75,12 @@ class Client(object):
|
|
|
75
75
|
msg = "Timeout occurred while connecting to Fyta-server"
|
|
76
76
|
raise FytaConnectionError(msg) from exception
|
|
77
77
|
|
|
78
|
-
#content_type = response.headers.get("Content-Type", "")
|
|
79
|
-
|
|
80
78
|
json_response = await response.json()
|
|
81
79
|
|
|
82
|
-
if json_response ==
|
|
80
|
+
if json_response == {"statusCode":404,"error":"Not Found"}:
|
|
83
81
|
_LOGGER.exception("Authentication failed")
|
|
84
82
|
raise FytaAuthentificationError
|
|
85
|
-
elif json_response ==
|
|
83
|
+
elif json_response == {"statusCode":401,"error":"Unauthorized","errors":[{"message":"Could not authenticate user"}]}:
|
|
86
84
|
raise FytaPasswordError
|
|
87
85
|
|
|
88
86
|
self.access_token = json_response["access_token"]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
import pytz
|
|
5
5
|
|
|
6
|
-
from fyta_client import Client
|
|
6
|
+
from .fyta_client import Client
|
|
7
7
|
|
|
8
8
|
PLANT_STATUS = {
|
|
9
9
|
1: "too low",
|
|
@@ -29,7 +29,7 @@ class FytaConnector(object):
|
|
|
29
29
|
return await self.client.test_connection()
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
async def login(self) ->
|
|
32
|
+
async def login(self) -> dict:
|
|
33
33
|
login = await self.client.login()
|
|
34
34
|
self.access_token = login["access_token"]
|
|
35
35
|
self.expiration = login["expiration"]
|
|
@@ -38,7 +38,7 @@ class FytaConnector(object):
|
|
|
38
38
|
return login
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
async def
|
|
41
|
+
async def update_plant_list(self):
|
|
42
42
|
self.plant_list = await self.client.get_plants()
|
|
43
43
|
|
|
44
44
|
return self.plant_list
|
|
@@ -47,7 +47,7 @@ class FytaConnector(object):
|
|
|
47
47
|
async def update_all_plants(self):
|
|
48
48
|
plants = {}
|
|
49
49
|
|
|
50
|
-
plant_list = await self.
|
|
50
|
+
plant_list = await self.update_plant_list()
|
|
51
51
|
|
|
52
52
|
for plant in plant_list.keys():
|
|
53
53
|
current_plant = await self.update_plant_data(plant)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|