python-terminusgps 37.1.0__py3-none-any.whl → 37.2.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 python-terminusgps might be problematic. Click here for more details.
- {python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.1.dist-info}/METADATA +1 -1
- {python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.1.dist-info}/RECORD +5 -5
- terminusgps/wialon/session.py +47 -17
- {python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.1.dist-info}/WHEEL +0 -0
- {python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.1.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 37.1
|
|
3
|
+
Version: 37.2.1
|
|
4
4
|
Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
|
|
5
5
|
Project-URL: Documentation, https://docs.terminusgps.com
|
|
6
6
|
Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
|
|
@@ -43,7 +43,7 @@ terminusgps/twilio/caller.py,sha256=RQax2iZ6SYHiuCvBxXkrooRWQ9J8DwKGAjxa8RYjrLI,
|
|
|
43
43
|
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
44
|
terminusgps/wialon/constants.py,sha256=05pLc_0S-x0tT87cQcxOmr8plesjOQxoXfUdjIHwI90,7732
|
|
45
45
|
terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
|
|
46
|
-
terminusgps/wialon/session.py,sha256=
|
|
46
|
+
terminusgps/wialon/session.py,sha256=kkfeqXg2akH_kytcTHsuga3RGpKn8bNcD8NeE3199F8,14843
|
|
47
47
|
terminusgps/wialon/utils.py,sha256=ntHLAVJSJBdIgJK704xxFNFRopaFz-No9YZZOMmvWO8,11627
|
|
48
48
|
terminusgps/wialon/validators.py,sha256=Z2eci8NzKDHU6oXl5ncgeYXmBYg336k-0R2m0DIxsDY,4346
|
|
49
49
|
terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
|
|
@@ -58,7 +58,7 @@ terminusgps/wialon/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
58
58
|
terminusgps/wialon/tests/test_items.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
59
59
|
terminusgps/wialon/tests/test_session.py,sha256=9mBlYchMo9NeqRIZsmxYzrM1zBHorqu4ooxqSNppLpI,1336
|
|
60
60
|
terminusgps/wialon/tests/test_utils.py,sha256=SK4PxJQGECFnzx_EQeRAQfsQ5_3FLaVcis2W9u_ibuI,1730
|
|
61
|
-
python_terminusgps-37.1.
|
|
62
|
-
python_terminusgps-37.1.
|
|
63
|
-
python_terminusgps-37.1.
|
|
64
|
-
python_terminusgps-37.1.
|
|
61
|
+
python_terminusgps-37.2.1.dist-info/METADATA,sha256=wAaM5nJUS8JGi3lRfXbpvkTIoDQ7g6mk3VZoTyl7hMg,1329
|
|
62
|
+
python_terminusgps-37.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
63
|
+
python_terminusgps-37.2.1.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
64
|
+
python_terminusgps-37.2.1.dist-info/RECORD,,
|
terminusgps/wialon/session.py
CHANGED
|
@@ -299,7 +299,7 @@ class WialonSession:
|
|
|
299
299
|
response = self.wialon_api.token_login(**{"token": token, "fl": flags})
|
|
300
300
|
self._set_login_response(response)
|
|
301
301
|
return response.get("eid")
|
|
302
|
-
except (wialon.api.WialonError,
|
|
302
|
+
except (wialon.api.WialonError, ValueError):
|
|
303
303
|
raise
|
|
304
304
|
|
|
305
305
|
def logout(self) -> None:
|
|
@@ -316,16 +316,20 @@ class WialonSession:
|
|
|
316
316
|
if response.get("error") != 0:
|
|
317
317
|
print(f"Failed to logout of session: '{response.get('message')}'")
|
|
318
318
|
|
|
319
|
-
def _set_login_response(self, login_response: dict) -> None:
|
|
319
|
+
def _set_login_response(self, login_response: dict | None) -> None:
|
|
320
320
|
"""
|
|
321
321
|
Sets the Wialon API session's attributes based on a login response.
|
|
322
322
|
|
|
323
323
|
:param login_response: A response returned from :py:meth:`login` or :py:meth:`duplicate`.
|
|
324
324
|
:type login_response: :py:obj:`dict`
|
|
325
|
+
:raises ValueError: If ``login_response`` wasn't provided.
|
|
325
326
|
:returns: Nothing.
|
|
326
327
|
:rtype: :py:obj:`None`
|
|
327
328
|
|
|
328
329
|
"""
|
|
330
|
+
if login_response is None:
|
|
331
|
+
raise ValueError("Failed to login to Wialon.")
|
|
332
|
+
|
|
329
333
|
self.wialon_api.sid = login_response.get("eid")
|
|
330
334
|
self._gis_geocode = login_response.get("gis_geocode")
|
|
331
335
|
self._gis_render = login_response.get("gis_render")
|
|
@@ -345,7 +349,13 @@ class WialonSession:
|
|
|
345
349
|
class WialonSessionManager:
|
|
346
350
|
"""Provides an interface for generating automatically activated Wialon sessions."""
|
|
347
351
|
|
|
348
|
-
def __init__(
|
|
352
|
+
def __init__(
|
|
353
|
+
self,
|
|
354
|
+
token: str | None = None,
|
|
355
|
+
lifetime: int = 500,
|
|
356
|
+
session: WialonSession | None = None,
|
|
357
|
+
session_id: str | None = None,
|
|
358
|
+
) -> None:
|
|
349
359
|
"""
|
|
350
360
|
Sets :py:attr:`token` and :py:attr:`lifetime`.
|
|
351
361
|
|
|
@@ -357,10 +367,13 @@ class WialonSessionManager:
|
|
|
357
367
|
:rtype: :py:obj:`None`
|
|
358
368
|
|
|
359
369
|
"""
|
|
360
|
-
self.
|
|
361
|
-
self.
|
|
362
|
-
|
|
363
|
-
|
|
370
|
+
self.token = token
|
|
371
|
+
self.lifetime = lifetime
|
|
372
|
+
|
|
373
|
+
target_sid = session.id if session and session.id else session_id
|
|
374
|
+
self.session = WialonSession(sid=target_sid)
|
|
375
|
+
if not target_sid or not self.validate_session():
|
|
376
|
+
self.session.login(token=self.token)
|
|
364
377
|
|
|
365
378
|
def check_active(self) -> bool:
|
|
366
379
|
"""
|
|
@@ -370,13 +383,18 @@ class WialonSessionManager:
|
|
|
370
383
|
:rtype: :py:obj:`bool`
|
|
371
384
|
|
|
372
385
|
"""
|
|
386
|
+
if not self.session.id:
|
|
387
|
+
return False
|
|
373
388
|
if not self.session.wialon_api.last_call_datetime:
|
|
374
|
-
return
|
|
389
|
+
return self.validate_session()
|
|
375
390
|
|
|
376
391
|
now = datetime.datetime.now()
|
|
377
392
|
last_call = self.session.wialon_api.last_call_datetime
|
|
378
393
|
session_expiry = last_call + datetime.timedelta(seconds=self.lifetime)
|
|
379
|
-
|
|
394
|
+
|
|
395
|
+
if now > session_expiry:
|
|
396
|
+
return False
|
|
397
|
+
return self.validate_session()
|
|
380
398
|
|
|
381
399
|
def get_session(self, sid: str | None = None) -> WialonSession:
|
|
382
400
|
"""
|
|
@@ -391,12 +409,23 @@ class WialonSessionManager:
|
|
|
391
409
|
|
|
392
410
|
"""
|
|
393
411
|
if sid is not None:
|
|
394
|
-
self.
|
|
412
|
+
self.session = WialonSession(sid=sid)
|
|
413
|
+
if not self.validate_session():
|
|
414
|
+
self.session = WialonSession()
|
|
415
|
+
self.session.login(token=self.token)
|
|
416
|
+
return self.session
|
|
395
417
|
if not self.check_active():
|
|
396
|
-
self.session = WialonSession(
|
|
397
|
-
self.session.login(self.token)
|
|
418
|
+
self.session = WialonSession()
|
|
419
|
+
self.session.login(token=self.token)
|
|
398
420
|
return self.session
|
|
399
421
|
|
|
422
|
+
def validate_session(self) -> bool:
|
|
423
|
+
try:
|
|
424
|
+
result = self.session.wialon_api.core_duplicate()
|
|
425
|
+
return result is not None
|
|
426
|
+
except wialon.api.WialonError:
|
|
427
|
+
return False
|
|
428
|
+
|
|
400
429
|
@property
|
|
401
430
|
def sid(self) -> str | None:
|
|
402
431
|
"""
|
|
@@ -405,7 +434,7 @@ class WialonSessionManager:
|
|
|
405
434
|
:type: :py:obj:`str` | :py:obj:`None`
|
|
406
435
|
|
|
407
436
|
"""
|
|
408
|
-
return self.session.wialon_api.sid
|
|
437
|
+
return self.session.wialon_api.sid if self.session else None
|
|
409
438
|
|
|
410
439
|
@sid.setter
|
|
411
440
|
def sid(self, other: str) -> None:
|
|
@@ -418,7 +447,10 @@ class WialonSessionManager:
|
|
|
418
447
|
:rtype: :py:obj:`None`
|
|
419
448
|
|
|
420
449
|
"""
|
|
421
|
-
self.session
|
|
450
|
+
if self.session:
|
|
451
|
+
self.session.wialon_api.sid = other
|
|
452
|
+
else:
|
|
453
|
+
self.session = WialonSession(sid=other)
|
|
422
454
|
|
|
423
455
|
@property
|
|
424
456
|
def token(self) -> str:
|
|
@@ -443,9 +475,7 @@ class WialonSessionManager:
|
|
|
443
475
|
:rtype: :py:obj:`None`
|
|
444
476
|
|
|
445
477
|
"""
|
|
446
|
-
if other is None
|
|
447
|
-
self._token = settings.WIALON_TOKEN
|
|
448
|
-
self._token = other
|
|
478
|
+
self._token = other if other is not None else settings.WIALON_TOKEN
|
|
449
479
|
|
|
450
480
|
@property
|
|
451
481
|
def session(self) -> WialonSession:
|
|
File without changes
|
{python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.1.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|