pysmarlaapi 0.6.2__py3-none-any.whl → 0.7.1__py3-none-any.whl
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.
Potentially problematic release.
This version of pysmarlaapi might be problematic. Click here for more details.
- pysmarlaapi/__init__.py +1 -1
- pysmarlaapi/classes/connection.py +17 -10
- pysmarlaapi/connection_hub/__init__.py +3 -3
- {pysmarlaapi-0.6.2.dist-info → pysmarlaapi-0.7.1.dist-info}/METADATA +1 -1
- {pysmarlaapi-0.6.2.dist-info → pysmarlaapi-0.7.1.dist-info}/RECORD +7 -7
- {pysmarlaapi-0.6.2.dist-info → pysmarlaapi-0.7.1.dist-info}/WHEEL +0 -0
- {pysmarlaapi-0.6.2.dist-info → pysmarlaapi-0.7.1.dist-info}/licenses/LICENSE +0 -0
pysmarlaapi/__init__.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
1
3
|
import aiohttp
|
|
2
4
|
import jsonpickle
|
|
3
5
|
|
|
@@ -23,18 +25,23 @@ class Connection:
|
|
|
23
25
|
return self.token.token
|
|
24
26
|
|
|
25
27
|
async def refresh_token(self) -> bool:
|
|
26
|
-
|
|
27
|
-
async with
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
try:
|
|
29
|
+
async with aiohttp.ClientSession(self.url) as session:
|
|
30
|
+
response = await session.post(
|
|
31
|
+
"/api/AppParing/getToken",
|
|
32
|
+
headers={"accept": "*/*", "Content-Type": "application/json"},
|
|
33
|
+
data=jsonpickle.encode(self.token, unpicklable=False),
|
|
34
|
+
)
|
|
35
|
+
except (aiohttp.ClientError, asyncio.TimeoutError):
|
|
36
|
+
return False
|
|
37
|
+
|
|
38
|
+
if response.status != 200:
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
content = await response.json()
|
|
35
42
|
|
|
36
43
|
try:
|
|
37
|
-
self.token = AuthToken.from_json(
|
|
44
|
+
self.token = AuthToken.from_json(content)
|
|
38
45
|
except ValueError:
|
|
39
46
|
return False
|
|
40
47
|
|
|
@@ -86,7 +86,7 @@ class ConnectionHub:
|
|
|
86
86
|
self.logger.info("Connection to server closed")
|
|
87
87
|
|
|
88
88
|
async def on_error(self, message):
|
|
89
|
-
self.logger.error("Connection error occurred: "
|
|
89
|
+
self.logger.error("Connection error occurred: %s", str(message))
|
|
90
90
|
|
|
91
91
|
def start(self):
|
|
92
92
|
if self.running:
|
|
@@ -107,7 +107,7 @@ class ConnectionHub:
|
|
|
107
107
|
try:
|
|
108
108
|
await self.client.run()
|
|
109
109
|
except Exception as e:
|
|
110
|
-
self.logger.warning(
|
|
110
|
+
self.logger.warning("Error during connection: %s: %s", type(e).__name__, str(e))
|
|
111
111
|
|
|
112
112
|
# Random backoff to avoid simultaneous connection attempts
|
|
113
113
|
backoff = random.randint(0, self._backoff)
|
|
@@ -136,7 +136,7 @@ class ConnectionHub:
|
|
|
136
136
|
if value is not None:
|
|
137
137
|
serialized_result["value"] = value
|
|
138
138
|
|
|
139
|
-
self.logger.debug(
|
|
139
|
+
self.logger.debug("Sending data, Event: %s, Payload: %s", event, str(serialized_result))
|
|
140
140
|
|
|
141
141
|
asyncio.run_coroutine_threadsafe(self.async_send_data(event, [serialized_result]), self._loop)
|
|
142
142
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
pysmarlaapi/__init__.py,sha256=
|
|
1
|
+
pysmarlaapi/__init__.py,sha256=rDgCmbkCZQZlhzANFZ4JVqkxlURuDWtkn4yS9HKCPqI,90
|
|
2
2
|
pysmarlaapi/classes/__init__.py,sha256=N-ZV3Id_t5ciovUlPUGCk5SLLiMUonRoQZWpfOU4ZsM,69
|
|
3
3
|
pysmarlaapi/classes/auth_token.py,sha256=dpo0lBT9Advm3Iyxu-fT9sq078U2OxgXXBuF5gbBZkM,942
|
|
4
|
-
pysmarlaapi/classes/connection.py,sha256=
|
|
5
|
-
pysmarlaapi/connection_hub/__init__.py,sha256=
|
|
4
|
+
pysmarlaapi/classes/connection.py,sha256=vbEHENKDUANCemQriH66sofHmPPCe2THSY9dm7SIt1M,1400
|
|
5
|
+
pysmarlaapi/connection_hub/__init__.py,sha256=NR5xql57L0Xs0JfeEVOVLITWSaVMblEo6pcvB7fn5TQ,4443
|
|
6
6
|
pysmarlaapi/federwiege/__init__.py,sha256=7Fl_GnwN6GbS8fhkHdfMhuYFospKnap40pvUtSGIeoE,1933
|
|
7
7
|
pysmarlaapi/federwiege/classes/__init__.py,sha256=DFJJVOKpra40S4ZX_oq2RyMazg6Nx0c8hoPggmj1bXA,60
|
|
8
8
|
pysmarlaapi/federwiege/classes/property.py,sha256=kTVbaGbWmmku5GmVq0mtWF8uSA7G8oHakyZ_LOO9h3c,1028
|
|
@@ -11,7 +11,7 @@ pysmarlaapi/federwiege/services/__init__.py,sha256=bJuOsk0lw9WWxB1NZodRTL8Pm_Ra8
|
|
|
11
11
|
pysmarlaapi/federwiege/services/analyser_service.py,sha256=y02j4cNvRAblBa1pTlJi1u1_7c3vV4xMj9uHe_vwV38,1789
|
|
12
12
|
pysmarlaapi/federwiege/services/babywiege_service.py,sha256=8hCu-uFAcT_G0F5oUD3EqYzb02L2bE5mVF72NrunEpc,2070
|
|
13
13
|
pysmarlaapi/federwiege/services/info_service.py,sha256=03a4eZFAL1zaIaWo1e-a_Zm2wVl0RuFLm2rTS7ABJIQ,1248
|
|
14
|
-
pysmarlaapi-0.
|
|
15
|
-
pysmarlaapi-0.
|
|
16
|
-
pysmarlaapi-0.
|
|
17
|
-
pysmarlaapi-0.
|
|
14
|
+
pysmarlaapi-0.7.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
15
|
+
pysmarlaapi-0.7.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
16
|
+
pysmarlaapi-0.7.1.dist-info/METADATA,sha256=bMPiRef95hRV4Yk2JT-2W6dbMGuPI1qAK0hZstD67MY,1106
|
|
17
|
+
pysmarlaapi-0.7.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|