python-terminusgps 37.1.0__py3-none-any.whl → 37.2.0__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.
- {python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.0.dist-info}/METADATA +1 -1
- {python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.0.dist-info}/RECORD +5 -5
- terminusgps/wialon/session.py +41 -15
- {python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.0.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 37.
|
|
3
|
+
Version: 37.2.0
|
|
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=bmVMpqotIYbHPsTqHGN6vkBZz4TfQv6ciGeh0xqxXw0,14678
|
|
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.
|
|
62
|
-
python_terminusgps-37.
|
|
63
|
-
python_terminusgps-37.
|
|
64
|
-
python_terminusgps-37.
|
|
61
|
+
python_terminusgps-37.2.0.dist-info/METADATA,sha256=rnvtTi8e_-85MBMfS6fRjLTJslnyDsttXghmKXsESoI,1329
|
|
62
|
+
python_terminusgps-37.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
63
|
+
python_terminusgps-37.2.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
64
|
+
python_terminusgps-37.2.0.dist-info/RECORD,,
|
terminusgps/wialon/session.py
CHANGED
|
@@ -345,7 +345,13 @@ class WialonSession:
|
|
|
345
345
|
class WialonSessionManager:
|
|
346
346
|
"""Provides an interface for generating automatically activated Wialon sessions."""
|
|
347
347
|
|
|
348
|
-
def __init__(
|
|
348
|
+
def __init__(
|
|
349
|
+
self,
|
|
350
|
+
token: str | None = None,
|
|
351
|
+
lifetime: int = 500,
|
|
352
|
+
session: WialonSession | None = None,
|
|
353
|
+
session_id: str | None = None,
|
|
354
|
+
) -> None:
|
|
349
355
|
"""
|
|
350
356
|
Sets :py:attr:`token` and :py:attr:`lifetime`.
|
|
351
357
|
|
|
@@ -357,10 +363,13 @@ class WialonSessionManager:
|
|
|
357
363
|
:rtype: :py:obj:`None`
|
|
358
364
|
|
|
359
365
|
"""
|
|
360
|
-
self.
|
|
361
|
-
self.
|
|
362
|
-
|
|
363
|
-
|
|
366
|
+
self.token = token
|
|
367
|
+
self.lifetime = lifetime
|
|
368
|
+
|
|
369
|
+
target_sid = session.id if session and session.id else session_id
|
|
370
|
+
self.session = WialonSession(sid=target_sid)
|
|
371
|
+
if not target_sid or not self.validate_session():
|
|
372
|
+
self.session.login(token=self.token)
|
|
364
373
|
|
|
365
374
|
def check_active(self) -> bool:
|
|
366
375
|
"""
|
|
@@ -370,13 +379,18 @@ class WialonSessionManager:
|
|
|
370
379
|
:rtype: :py:obj:`bool`
|
|
371
380
|
|
|
372
381
|
"""
|
|
382
|
+
if not self.session.id:
|
|
383
|
+
return False
|
|
373
384
|
if not self.session.wialon_api.last_call_datetime:
|
|
374
|
-
return
|
|
385
|
+
return self.validate_session()
|
|
375
386
|
|
|
376
387
|
now = datetime.datetime.now()
|
|
377
388
|
last_call = self.session.wialon_api.last_call_datetime
|
|
378
389
|
session_expiry = last_call + datetime.timedelta(seconds=self.lifetime)
|
|
379
|
-
|
|
390
|
+
|
|
391
|
+
if now > session_expiry:
|
|
392
|
+
return False
|
|
393
|
+
return self.validate_session()
|
|
380
394
|
|
|
381
395
|
def get_session(self, sid: str | None = None) -> WialonSession:
|
|
382
396
|
"""
|
|
@@ -391,12 +405,23 @@ class WialonSessionManager:
|
|
|
391
405
|
|
|
392
406
|
"""
|
|
393
407
|
if sid is not None:
|
|
394
|
-
self.
|
|
408
|
+
self.session = WialonSession(sid=sid)
|
|
409
|
+
if not self.validate_session():
|
|
410
|
+
self.session = WialonSession()
|
|
411
|
+
self.session.login(token=self.token)
|
|
412
|
+
return self.session
|
|
395
413
|
if not self.check_active():
|
|
396
|
-
self.session = WialonSession(
|
|
397
|
-
self.session.login(self.token)
|
|
414
|
+
self.session = WialonSession()
|
|
415
|
+
self.session.login(token=self.token)
|
|
398
416
|
return self.session
|
|
399
417
|
|
|
418
|
+
def validate_session(self) -> bool:
|
|
419
|
+
try:
|
|
420
|
+
result = self.session.wialon_api.core_duplicate()
|
|
421
|
+
return result is not None
|
|
422
|
+
except wialon.api.WialonError:
|
|
423
|
+
return False
|
|
424
|
+
|
|
400
425
|
@property
|
|
401
426
|
def sid(self) -> str | None:
|
|
402
427
|
"""
|
|
@@ -405,7 +430,7 @@ class WialonSessionManager:
|
|
|
405
430
|
:type: :py:obj:`str` | :py:obj:`None`
|
|
406
431
|
|
|
407
432
|
"""
|
|
408
|
-
return self.session.wialon_api.sid
|
|
433
|
+
return self.session.wialon_api.sid if self.session else None
|
|
409
434
|
|
|
410
435
|
@sid.setter
|
|
411
436
|
def sid(self, other: str) -> None:
|
|
@@ -418,7 +443,10 @@ class WialonSessionManager:
|
|
|
418
443
|
:rtype: :py:obj:`None`
|
|
419
444
|
|
|
420
445
|
"""
|
|
421
|
-
self.session
|
|
446
|
+
if self.session:
|
|
447
|
+
self.session.wialon_api.sid = other
|
|
448
|
+
else:
|
|
449
|
+
self.session = WialonSession(sid=other)
|
|
422
450
|
|
|
423
451
|
@property
|
|
424
452
|
def token(self) -> str:
|
|
@@ -443,9 +471,7 @@ class WialonSessionManager:
|
|
|
443
471
|
:rtype: :py:obj:`None`
|
|
444
472
|
|
|
445
473
|
"""
|
|
446
|
-
if other is None
|
|
447
|
-
self._token = settings.WIALON_TOKEN
|
|
448
|
-
self._token = other
|
|
474
|
+
self._token = other if other is not None else settings.WIALON_TOKEN
|
|
449
475
|
|
|
450
476
|
@property
|
|
451
477
|
def session(self) -> WialonSession:
|
|
File without changes
|
{python_terminusgps-37.1.0.dist-info → python_terminusgps-37.2.0.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|