python-terminusgps 31.7.0__py3-none-any.whl → 31.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 python-terminusgps might be problematic. Click here for more details.
- {python_terminusgps-31.7.0.dist-info → python_terminusgps-31.7.1.dist-info}/METADATA +2 -2
- {python_terminusgps-31.7.0.dist-info → python_terminusgps-31.7.1.dist-info}/RECORD +8 -8
- terminusgps/wialon/constants.py +27 -7
- terminusgps/wialon/session.py +25 -23
- terminusgps/wialon/tests/test_session.py +9 -7
- terminusgps/wialon/tests/test_utils.py +0 -1
- {python_terminusgps-31.7.0.dist-info → python_terminusgps-31.7.1.dist-info}/WHEEL +0 -0
- {python_terminusgps-31.7.0.dist-info → python_terminusgps-31.7.1.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 31.7.
|
|
3
|
+
Version: 31.7.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
|
|
@@ -16,8 +16,8 @@ Requires-Dist: argparse>=1.4.0
|
|
|
16
16
|
Requires-Dist: authorizenet>=1.1.5
|
|
17
17
|
Requires-Dist: boto3>=1.34.144
|
|
18
18
|
Requires-Dist: django>=5.1.5
|
|
19
|
+
Requires-Dist: loguru>=0.7.3
|
|
19
20
|
Requires-Dist: matplotlib>=3.10.1
|
|
20
|
-
Requires-Dist: opencv-contrib-python-headless>=4.11.0.86
|
|
21
21
|
Requires-Dist: pandas>=2.2.3
|
|
22
22
|
Requires-Dist: python-wialon>=1.2.4
|
|
23
23
|
Requires-Dist: pyzbar>=0.1.9
|
|
@@ -28,10 +28,10 @@ terminusgps/twilio/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
28
28
|
terminusgps/twilio/tests/test_caller.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
29
|
terminusgps/twilio/tests/test_validators.py,sha256=CETv7Mcr19UMMfh1UaWSV26FiOeh2WCK_VutfKXnf7g,1428
|
|
30
30
|
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
|
-
terminusgps/wialon/constants.py,sha256=
|
|
31
|
+
terminusgps/wialon/constants.py,sha256=Ju2XL2A4DPFD-w8NjYqEfnnqregl1luPT0XGhGSUnO8,6316
|
|
32
32
|
terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
|
|
33
33
|
terminusgps/wialon/logger.py,sha256=nUBsaLMaffSaAHGHAM6mFXDzix9hbNecVtA3INVtii8,968
|
|
34
|
-
terminusgps/wialon/session.py,sha256=
|
|
34
|
+
terminusgps/wialon/session.py,sha256=Ata_eDn4fzTkvl0A1MNHwlFx-G9aVayXMo40lcS3pY4,10007
|
|
35
35
|
terminusgps/wialon/utils.py,sha256=JWHZ7VEeo8VNBH67gjOAQk5ITKuPllWDlJ4dVSQ5blA,11002
|
|
36
36
|
terminusgps/wialon/validators.py,sha256=CVEpFsxqplEcpv4U2ipA6v9y5cSrMKFUXLvze-3vs4U,4223
|
|
37
37
|
terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
|
|
@@ -44,9 +44,9 @@ terminusgps/wialon/items/unit_group.py,sha256=QV2ZZgICaN3n6W1pFIyMLyNKB6KYBsLyKG
|
|
|
44
44
|
terminusgps/wialon/items/user.py,sha256=5LgwalGO8KS_7psmAVmAlnC0S6SPBDZMOuT5ZqPKRmo,7758
|
|
45
45
|
terminusgps/wialon/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
46
|
terminusgps/wialon/tests/test_items.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
|
-
terminusgps/wialon/tests/test_session.py,sha256=
|
|
48
|
-
terminusgps/wialon/tests/test_utils.py,sha256=
|
|
49
|
-
python_terminusgps-31.7.
|
|
50
|
-
python_terminusgps-31.7.
|
|
51
|
-
python_terminusgps-31.7.
|
|
52
|
-
python_terminusgps-31.7.
|
|
47
|
+
terminusgps/wialon/tests/test_session.py,sha256=9mBlYchMo9NeqRIZsmxYzrM1zBHorqu4ooxqSNppLpI,1336
|
|
48
|
+
terminusgps/wialon/tests/test_utils.py,sha256=dEcGDP_mVbT_uEMfdodAxc6Dcehn_ZwZswp8nYtdNvA,1669
|
|
49
|
+
python_terminusgps-31.7.1.dist-info/METADATA,sha256=nph4QwpwpHjYR-rz25kOtOlWPuMvvu5t_YsBzq0QtT8,1581
|
|
50
|
+
python_terminusgps-31.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
51
|
+
python_terminusgps-31.7.1.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
52
|
+
python_terminusgps-31.7.1.dist-info/RECORD,,
|
terminusgps/wialon/constants.py
CHANGED
|
@@ -5,15 +5,35 @@ from . import flags
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class WialonGeofenceType(enum.IntEnum):
|
|
8
|
+
"""
|
|
9
|
+
A type of Wialon geofence.
|
|
10
|
+
|
|
11
|
+
`Wialon geofence type reference <https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/resource/update_zone>`_
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
|
|
8
15
|
LINE = 1
|
|
16
|
+
"""Line geofence."""
|
|
9
17
|
POLYGON = 2
|
|
18
|
+
"""Polygon geofence."""
|
|
10
19
|
CIRCLE = 3
|
|
20
|
+
"""Circular geofence."""
|
|
11
21
|
|
|
12
22
|
|
|
13
23
|
class WialonMeasurementUnit(enum.IntEnum):
|
|
24
|
+
"""
|
|
25
|
+
A Wialon measurement unit.
|
|
26
|
+
|
|
27
|
+
`Wialon measurement unit reference <https://sdk.wialon.com/wiki/en/local/remoteapi1904/apiref/item/update_measure_units>`_
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
14
31
|
METRIC = 0
|
|
32
|
+
"""Metric system."""
|
|
15
33
|
US = 1
|
|
34
|
+
"""US measurement system."""
|
|
16
35
|
IMPERIAL = 2
|
|
36
|
+
"""Imperial measurement system."""
|
|
17
37
|
|
|
18
38
|
|
|
19
39
|
class WialonItemsType(enum.StrEnum):
|
|
@@ -25,19 +45,19 @@ class WialonItemsType(enum.StrEnum):
|
|
|
25
45
|
"""
|
|
26
46
|
|
|
27
47
|
HARDWARE = "avl_hw"
|
|
28
|
-
"""
|
|
48
|
+
"""A hardware type."""
|
|
29
49
|
RESOURCE = "avl_resource"
|
|
30
|
-
"""
|
|
50
|
+
"""A resource."""
|
|
31
51
|
RETRANSLATOR = "avl_retranslator"
|
|
32
|
-
"""
|
|
52
|
+
"""A retranslator."""
|
|
33
53
|
ROUTE = "avl_route"
|
|
34
|
-
"""
|
|
54
|
+
"""A route."""
|
|
35
55
|
UNIT = "avl_unit"
|
|
36
|
-
"""
|
|
56
|
+
"""A unit."""
|
|
37
57
|
UNIT_GROUP = "avl_unit_group"
|
|
38
|
-
"""
|
|
58
|
+
"""A unit group."""
|
|
39
59
|
USER = "user"
|
|
40
|
-
"""
|
|
60
|
+
"""A user."""
|
|
41
61
|
|
|
42
62
|
|
|
43
63
|
class WialonItemProperty(enum.StrEnum):
|
terminusgps/wialon/session.py
CHANGED
|
@@ -6,8 +6,7 @@ import typing
|
|
|
6
6
|
import wialon.api
|
|
7
7
|
from django.conf import settings
|
|
8
8
|
from django.utils import timezone
|
|
9
|
-
|
|
10
|
-
from terminusgps.wialon.logger import WialonLogger
|
|
9
|
+
from loguru import logger
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
@dataclasses.dataclass
|
|
@@ -24,9 +23,7 @@ class Wialon(wialon.api.Wialon):
|
|
|
24
23
|
def __init__(self, log_level: int = logging.INFO, *args, **kwargs) -> None:
|
|
25
24
|
super().__init__(*args, **kwargs)
|
|
26
25
|
self.call_history: list[WialonAPICall] = []
|
|
27
|
-
self.
|
|
28
|
-
logging.getLogger(self.__class__.__name__), level=log_level
|
|
29
|
-
).get_logger()
|
|
26
|
+
logger.add(self.__class__.__name__, level=log_level)
|
|
30
27
|
|
|
31
28
|
@property
|
|
32
29
|
def total_calls(self) -> int:
|
|
@@ -37,7 +34,7 @@ class Wialon(wialon.api.Wialon):
|
|
|
37
34
|
return self.call("token_login", *args, **kwargs)
|
|
38
35
|
|
|
39
36
|
def call(self, action_name: str, *argc, **kwargs) -> typing.Any:
|
|
40
|
-
|
|
37
|
+
logger.debug(f"Executing '{action_name}'...")
|
|
41
38
|
call_record = WialonAPICall(
|
|
42
39
|
action=action_name, timestamp=timezone.now(), args=argc, kwargs=kwargs
|
|
43
40
|
)
|
|
@@ -45,11 +42,11 @@ class Wialon(wialon.api.Wialon):
|
|
|
45
42
|
try:
|
|
46
43
|
result = super().call(action_name, *argc, **kwargs)
|
|
47
44
|
call_record.result = result
|
|
48
|
-
|
|
45
|
+
logger.debug(f"Executed '{action_name}' successfully.")
|
|
49
46
|
return result
|
|
50
47
|
except wialon.api.WialonError as e:
|
|
51
48
|
call_record.error = e
|
|
52
|
-
|
|
49
|
+
logger.warning(f"Failed to execute '{action_name}': '{e}'")
|
|
53
50
|
return
|
|
54
51
|
finally:
|
|
55
52
|
self.call_history.append(call_record)
|
|
@@ -78,25 +75,21 @@ class WialonSession:
|
|
|
78
75
|
:type host: :py:obj:`str`
|
|
79
76
|
:param port: Wialon API host port. Default is ``443``.
|
|
80
77
|
:type port: :py:obj:`int`
|
|
81
|
-
:param log_level:
|
|
78
|
+
:param log_level: Level of emitted logs. Default is :py:obj:`~logging.INFO`.
|
|
82
79
|
:type log_level: :py:obj:`int`
|
|
83
80
|
:returns: Nothing.
|
|
84
81
|
:rtype: :py:obj:`None`
|
|
85
82
|
|
|
86
83
|
"""
|
|
87
84
|
|
|
85
|
+
logger.add(self.__class__.__name__, level=log_level)
|
|
88
86
|
self._token = token or settings.WIALON_TOKEN
|
|
89
87
|
self._username = None
|
|
90
88
|
self._gis_sid = None
|
|
91
89
|
self._hw_gp_ip = None
|
|
92
90
|
self._wsdk_version = None
|
|
93
91
|
self._uid = None
|
|
94
|
-
self.wialon_api = Wialon(
|
|
95
|
-
scheme=scheme, host=host, port=port, sid=sid, log_level=log_level
|
|
96
|
-
)
|
|
97
|
-
self.logger = WialonLogger(
|
|
98
|
-
logging.getLogger(self.__class__.__name__), level=log_level
|
|
99
|
-
).get_logger()
|
|
92
|
+
self.wialon_api = Wialon(scheme=scheme, host=host, port=port, sid=sid)
|
|
100
93
|
|
|
101
94
|
def __str__(self) -> str:
|
|
102
95
|
return str(self.id)
|
|
@@ -127,6 +120,17 @@ class WialonSession:
|
|
|
127
120
|
"""
|
|
128
121
|
self.logout()
|
|
129
122
|
|
|
123
|
+
@property
|
|
124
|
+
def active(self) -> bool:
|
|
125
|
+
"""
|
|
126
|
+
Whether or not the session is logged in.
|
|
127
|
+
|
|
128
|
+
:type: :py:obj:`bool`
|
|
129
|
+
:value: :py:obj:`False`
|
|
130
|
+
|
|
131
|
+
"""
|
|
132
|
+
return bool(self.id)
|
|
133
|
+
|
|
130
134
|
@property
|
|
131
135
|
def gis_geocode(self) -> str | None:
|
|
132
136
|
"""
|
|
@@ -288,13 +292,13 @@ class WialonSession:
|
|
|
288
292
|
|
|
289
293
|
"""
|
|
290
294
|
try:
|
|
291
|
-
|
|
295
|
+
logger.debug("Logging into Wialon API session...")
|
|
292
296
|
response = self.wialon_api.token_login(**{"token": token, "fl": flags})
|
|
293
297
|
self._set_login_response(response)
|
|
294
|
-
|
|
298
|
+
logger.debug(f"Logged into Wialon API session '{response.get('eid')}'")
|
|
295
299
|
return response.get("eid")
|
|
296
300
|
except (wialon.api.WialonError, AssertionError) as e:
|
|
297
|
-
|
|
301
|
+
logger.critical(f"Failed to login to Wialon API: '{e}'")
|
|
298
302
|
raise
|
|
299
303
|
|
|
300
304
|
def logout(self) -> None:
|
|
@@ -305,16 +309,14 @@ class WialonSession:
|
|
|
305
309
|
:rtype: :py:obj:`None`
|
|
306
310
|
|
|
307
311
|
"""
|
|
308
|
-
|
|
312
|
+
logger.debug("Logging out of Wialon API session...")
|
|
309
313
|
response: dict = self.wialon_api.core_logout({})
|
|
310
314
|
self.wialon_api.sid = None
|
|
311
315
|
|
|
312
316
|
if response.get("error") != 0:
|
|
313
|
-
|
|
314
|
-
f"Failed to logout of session: '{response.get('message')}'"
|
|
315
|
-
)
|
|
317
|
+
logger.warning(f"Failed to logout of session: '{response.get('message')}'")
|
|
316
318
|
else:
|
|
317
|
-
|
|
319
|
+
logger.debug(
|
|
318
320
|
f"Logged out after {self.wialon_api.total_calls} Wialon API calls."
|
|
319
321
|
)
|
|
320
322
|
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
import os
|
|
1
2
|
import unittest
|
|
2
3
|
|
|
3
4
|
from django.conf import settings
|
|
4
5
|
|
|
5
|
-
from
|
|
6
|
+
from terminusgps.wialon.session import WialonSession
|
|
7
|
+
|
|
8
|
+
TEST_WIALON_TOKEN = os.getenv("WIALON_TOKEN") or settings.WIALON_TOKEN
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
class WialonSessionTestCase(unittest.TestCase):
|
|
9
12
|
def setUp(self) -> None:
|
|
10
|
-
|
|
11
|
-
self.fail("'WIALON_TOKEN' setting is required.")
|
|
12
|
-
|
|
13
|
-
self.token = settings.WIALON_TOKEN
|
|
13
|
+
self.token = TEST_WIALON_TOKEN
|
|
14
14
|
self.session = WialonSession()
|
|
15
15
|
|
|
16
|
+
def tearDown(self) -> None:
|
|
17
|
+
if self.session.active:
|
|
18
|
+
self.session.logout()
|
|
19
|
+
|
|
16
20
|
def test_session_init(self) -> None:
|
|
17
21
|
self.assertIsNone(self.session.id)
|
|
18
22
|
self.assertIsNone(self.session.username)
|
|
@@ -31,10 +35,8 @@ class WialonSessionTestCase(unittest.TestCase):
|
|
|
31
35
|
self.session.login(self.token)
|
|
32
36
|
response = self.session.wialon_api.core_bad_call({})
|
|
33
37
|
self.assertIsNone(response)
|
|
34
|
-
self.session.logout()
|
|
35
38
|
|
|
36
39
|
def test_session_valid_call_count(self) -> None:
|
|
37
40
|
self.session.login(self.token) # Login/logout does not count
|
|
38
41
|
self.session.wialon_api.avl_evts()
|
|
39
42
|
self.assertEqual(self.session.wialon_api.total_calls, 1)
|
|
40
|
-
self.session.logout()
|
|
File without changes
|
{python_terminusgps-31.7.0.dist-info → python_terminusgps-31.7.1.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|