python-terminusgps 1.5.10__py3-none-any.whl → 1.6.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-1.5.10.dist-info → python_terminusgps-1.6.0.dist-info}/METADATA +1 -1
- {python_terminusgps-1.5.10.dist-info → python_terminusgps-1.6.0.dist-info}/RECORD +5 -5
- terminusgps/wialon/session.py +21 -8
- {python_terminusgps-1.5.10.dist-info → python_terminusgps-1.6.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-1.5.10.dist-info → python_terminusgps-1.6.0.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.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://app.terminusgps.com/docs/apps/python-terminusgps/index.html
|
|
6
6
|
Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
|
|
@@ -8,7 +8,7 @@ terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
|
8
8
|
terminusgps/wialon/constants.py,sha256=dsQaNt3TIjIZbr_m94KmBGFdrqe6HER2r6lol3X8QpU,2802
|
|
9
9
|
terminusgps/wialon/errors.py,sha256=SV9pVwU6FZ_zGlGP6zJN6aLE2auF4TfHFISQLiPMKrI,1758
|
|
10
10
|
terminusgps/wialon/flags.py,sha256=-OoH-eZM54yjRqxsAXL8VImdQu_7C0OAxCrFqaCEuko,13510
|
|
11
|
-
terminusgps/wialon/session.py,sha256=
|
|
11
|
+
terminusgps/wialon/session.py,sha256=PNtEooiJln3yZ_hSZXglciyN-H1W6_X5NbLFP5Ju0Ns,9987
|
|
12
12
|
terminusgps/wialon/utils.py,sha256=cDz00d5Jopdh-Al-554-yD5LrKQ37hq4YBXvPunnmIg,2715
|
|
13
13
|
terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
|
|
14
14
|
terminusgps/wialon/items/base.py,sha256=MN4FG6U1nWkYAjNfXQJRVrWJoiW4Y64tyqxUO0mhv_w,6593
|
|
@@ -18,7 +18,7 @@ terminusgps/wialon/items/route.py,sha256=qOHPN_rejwiGqvwWzlwmUIAIyc3lKavCalf8ki6
|
|
|
18
18
|
terminusgps/wialon/items/unit.py,sha256=tLAWPfHUUS6_Feh1aYBMFPgyuGlSiAnfumJJmGt3bKw,4662
|
|
19
19
|
terminusgps/wialon/items/unit_group.py,sha256=1yc7ldPIgGbtiTj0djRDWmt6Q9K_VT9sxOaioasbbLY,5212
|
|
20
20
|
terminusgps/wialon/items/user.py,sha256=bkcMw_YiocaMuhP_pBfB7apjAZwnsOzGScnGkn8Ybbw,6107
|
|
21
|
-
python_terminusgps-1.
|
|
22
|
-
python_terminusgps-1.
|
|
23
|
-
python_terminusgps-1.
|
|
24
|
-
python_terminusgps-1.
|
|
21
|
+
python_terminusgps-1.6.0.dist-info/METADATA,sha256=VBNWqHqXEN2Ig3nLeZrGOPrt_0Hrja2YPYfpMPdfrhA,882
|
|
22
|
+
python_terminusgps-1.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
23
|
+
python_terminusgps-1.6.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
24
|
+
python_terminusgps-1.6.0.dist-info/RECORD,,
|
terminusgps/wialon/session.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import threading
|
|
2
|
+
|
|
1
3
|
from wialon.api import Wialon, WialonError
|
|
2
4
|
from django.conf import settings
|
|
3
5
|
from django.core.exceptions import ImproperlyConfigured
|
|
@@ -307,13 +309,24 @@ class WialonSession:
|
|
|
307
309
|
self._wsdk_version = login_response.get("wsdk_version")
|
|
308
310
|
|
|
309
311
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
312
|
+
class WialonSessionManager:
|
|
313
|
+
_instance = None
|
|
314
|
+
_lock = threading.Lock()
|
|
315
|
+
_session = None
|
|
316
|
+
|
|
317
|
+
def __new__(cls) -> "WialonSessionManager":
|
|
318
|
+
with cls._lock:
|
|
319
|
+
if not cls._instance:
|
|
320
|
+
cls._instance = super().__new__(cls)
|
|
321
|
+
return cls._instance
|
|
316
322
|
|
|
323
|
+
def get_session(self, sid: str | None = None) -> WialonSession:
|
|
324
|
+
if not hasattr(settings, "WIALON_TOKEN"):
|
|
325
|
+
raise ImproperlyConfigured("'WIALON_TOKEN' setting is required.")
|
|
317
326
|
|
|
318
|
-
|
|
319
|
-
|
|
327
|
+
with self._lock:
|
|
328
|
+
if not self._session or not self._session.active:
|
|
329
|
+
self._session = WialonSession(sid=sid)
|
|
330
|
+
if not self._session.active:
|
|
331
|
+
self._session.login(settings.WIALON_TOKEN)
|
|
332
|
+
return self._session
|
|
File without changes
|
|
File without changes
|