python-terminusgps 1.16.0__py3-none-any.whl → 1.18.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.
Potentially problematic release.
This version of python-terminusgps might be problematic. Click here for more details.
- {python_terminusgps-1.16.0.dist-info → python_terminusgps-1.18.0.dist-info}/METADATA +1 -1
- {python_terminusgps-1.16.0.dist-info → python_terminusgps-1.18.0.dist-info}/RECORD +17 -16
- terminusgps/wialon/constants.py +1 -38
- terminusgps/wialon/items/__init__.py +1 -0
- terminusgps/wialon/items/base.py +2 -7
- terminusgps/wialon/items/geofence.py +57 -0
- terminusgps/wialon/items/notification.py +1 -30
- terminusgps/wialon/items/resource.py +21 -12
- terminusgps/wialon/items/retranslator.py +10 -14
- terminusgps/wialon/items/route.py +20 -11
- terminusgps/wialon/items/unit.py +14 -14
- terminusgps/wialon/items/unit_group.py +9 -10
- terminusgps/wialon/items/user.py +12 -15
- terminusgps/wialon/session.py +0 -13
- terminusgps/wialon/utils.py +23 -11
- {python_terminusgps-1.16.0.dist-info → python_terminusgps-1.18.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-1.16.0.dist-info → python_terminusgps-1.18.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.18.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
|
|
@@ -14,21 +14,22 @@ terminusgps/aws/ses.py,sha256=sDca2GjMaZvUt3kUPtGCpcqHiOkij9lMV1ogZofgYUU,2372
|
|
|
14
14
|
terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
|
|
15
15
|
terminusgps/twilio/caller.py,sha256=nHCIwUulo-C_v2orsp6OY0nuJA6YetSkxpMTwrRQ-uA,1831
|
|
16
16
|
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
terminusgps/wialon/constants.py,sha256=
|
|
17
|
+
terminusgps/wialon/constants.py,sha256=upk4Jb3b4BviaMIBTnDbFgYCSTZi-HnjhMfAJkKwfLI,1638
|
|
18
18
|
terminusgps/wialon/errors.py,sha256=Fl8A0peF5HpDdR3y0r3g86-iQ4kQgye3FYQZKGe3T7Y,984
|
|
19
19
|
terminusgps/wialon/flags.py,sha256=-OoH-eZM54yjRqxsAXL8VImdQu_7C0OAxCrFqaCEuko,13510
|
|
20
|
-
terminusgps/wialon/session.py,sha256=
|
|
21
|
-
terminusgps/wialon/utils.py,sha256=
|
|
22
|
-
terminusgps/wialon/items/__init__.py,sha256=
|
|
23
|
-
terminusgps/wialon/items/base.py,sha256
|
|
24
|
-
terminusgps/wialon/items/
|
|
25
|
-
terminusgps/wialon/items/
|
|
26
|
-
terminusgps/wialon/items/
|
|
27
|
-
terminusgps/wialon/items/
|
|
28
|
-
terminusgps/wialon/items/
|
|
29
|
-
terminusgps/wialon/items/
|
|
30
|
-
terminusgps/wialon/items/
|
|
31
|
-
|
|
32
|
-
python_terminusgps-1.
|
|
33
|
-
python_terminusgps-1.
|
|
34
|
-
python_terminusgps-1.
|
|
20
|
+
terminusgps/wialon/session.py,sha256=zCM3VXzRn8OhR34_3E45I2dPD9NtmFfKJOwKZzxerOs,10857
|
|
21
|
+
terminusgps/wialon/utils.py,sha256=KeZmV-MEdGOHXrsyn6IIoyX0EgVYiWYjvacXyZVr1u8,6501
|
|
22
|
+
terminusgps/wialon/items/__init__.py,sha256=cfUC5sfVsTwmpgsR-w9wA4ay6_EZYAPgEeuw2k06RJM,256
|
|
23
|
+
terminusgps/wialon/items/base.py,sha256=EAtzlnCvB7WTu3iX1bV1-S9TvwXc-Eez7e0X4TMiK9U,6943
|
|
24
|
+
terminusgps/wialon/items/geofence.py,sha256=auT3QDe3Vmuky9A2gsaMQUbqNqRX8HJGwl1nBXX41zk,1661
|
|
25
|
+
terminusgps/wialon/items/notification.py,sha256=6IrswN6fdEkJErIqtMq45bTl9xVARQw8nokDsy3x1MA,97
|
|
26
|
+
terminusgps/wialon/items/resource.py,sha256=79SwbCyE1zlaoeBfU0erEqvqBAYUC4KAKs8AOLJqflU,9652
|
|
27
|
+
terminusgps/wialon/items/retranslator.py,sha256=8q9EDc92w92MElnHIeEzH3Ra4kiPXrx4t9V5nPDZuRU,3728
|
|
28
|
+
terminusgps/wialon/items/route.py,sha256=PTJx1gmT_PGz7nlSSUS2VzjYD-aAuvkEOIdIFneUSSQ,1148
|
|
29
|
+
terminusgps/wialon/items/unit.py,sha256=PwF7xlpDWI5MpM_u6TmYZjNHWk6TSKM4rJ4OB9CIn4A,7533
|
|
30
|
+
terminusgps/wialon/items/unit_group.py,sha256=xc7zYitPE59_WYS-G857jeIQnQcUAxLBH3X6Y1VDg_8,4089
|
|
31
|
+
terminusgps/wialon/items/user.py,sha256=INwAibQVmjNNelepQXMfDevgJqMvIjHHgEjAMLRvhB0,7082
|
|
32
|
+
python_terminusgps-1.18.0.dist-info/METADATA,sha256=jK5eBo6X_WVCvAoo-CIjkt1qaub2WlN8TXTV5zCALTw,912
|
|
33
|
+
python_terminusgps-1.18.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
34
|
+
python_terminusgps-1.18.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
35
|
+
python_terminusgps-1.18.0.dist-info/RECORD,,
|
terminusgps/wialon/constants.py
CHANGED
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
from django.db import models
|
|
2
|
-
from django.utils.translation import gettext_lazy as _
|
|
3
|
-
|
|
4
1
|
from terminusgps.wialon import flags
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
class WialonCommandName(models.TextChoices):
|
|
8
|
-
SUB_BASIC = "Basic", _("Basic Subscription")
|
|
9
|
-
SUB_STANDARD = "Standard", _("Standard Subscription")
|
|
10
|
-
SUB_PREMIUM = "Premium", _("Premium Subscription")
|
|
11
|
-
STARTER_DISABLED = "Starter Disable On", _("Disable Starter")
|
|
12
|
-
STARTER_ENABLED = "Starter Disable Off", _("Enable Starter")
|
|
13
|
-
ENABLE = "On", _("Enable")
|
|
14
|
-
DISABLE = "Off", _("Disable")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class WialonCommandType(models.TextChoices):
|
|
18
|
-
ENGINE_BLOCK = "block_engine", _("Block Engine")
|
|
19
|
-
ENGINE_UNBLOCK = "unblock_engine", _("Unblock Engine")
|
|
20
|
-
CUSTOM_MSG = "custom_msg", _("Custom Message")
|
|
21
|
-
DRIVER_MSG = "driver_msg", _("Message to Driver")
|
|
22
|
-
DOWNLOAD_MSG = "download_msgs", _("Download messages")
|
|
23
|
-
QUERY_POS = "query_pos", _("Query Position")
|
|
24
|
-
QUERY_PHOTO = "query_photo", _("Query Snapshot")
|
|
25
|
-
OUTPUT_ON = "output_on", _("Activate Output")
|
|
26
|
-
OUTPUT_OFF = "output_off", _("Deactive Output")
|
|
27
|
-
SEND_POS = "send_position", _("Send Coordinates")
|
|
28
|
-
SET_REPORT_INT = "set_report_interval", _("Set Data Transfer Interval")
|
|
29
|
-
UPLOAD_CFG = "upload_cfg", _("Upload Configuration")
|
|
30
|
-
UPLOAD_SW = "upload_sw", _("Upload Firmware")
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class WialonCommandLink(models.TextChoices):
|
|
34
|
-
AUTO = "", _("Auto")
|
|
35
|
-
TCP = "tcp", _("TCP")
|
|
36
|
-
UDP = "udp", _("UDP")
|
|
37
|
-
VRT = "vrt", _("Virtual")
|
|
38
|
-
GSM = "gsm", _("SMS")
|
|
39
|
-
|
|
3
|
+
ACCESSMASK_UNIT_FULL: int = flags.ACCESSFLAG_FULL_ACCESS
|
|
40
4
|
|
|
41
5
|
ACCESSMASK_UNIT_BASIC: int = sum(
|
|
42
6
|
[
|
|
@@ -74,7 +38,6 @@ ACCESSMASK_UNIT_SUPER: int = sum(
|
|
|
74
38
|
]
|
|
75
39
|
)
|
|
76
40
|
|
|
77
|
-
ACCESSMASK_UNIT_FULL: int = flags.ACCESSFLAG_FULL_ACCESS
|
|
78
41
|
|
|
79
42
|
ACCESSMASK_UNIT_MIGRATION: int = sum(
|
|
80
43
|
[
|
terminusgps/wialon/items/base.py
CHANGED
|
@@ -7,18 +7,13 @@ from terminusgps.wialon.session import WialonSession
|
|
|
7
7
|
|
|
8
8
|
class WialonBase:
|
|
9
9
|
def __init__(
|
|
10
|
-
self,
|
|
11
|
-
id: str | int | None = None,
|
|
12
|
-
session: WialonSession | None = None,
|
|
13
|
-
**kwargs,
|
|
10
|
+
self, id: str | int | None, session: WialonSession, *args, **kwargs
|
|
14
11
|
) -> None:
|
|
15
|
-
if session is None:
|
|
16
|
-
raise ValueError("A valid Wialon API session is required.")
|
|
17
12
|
if isinstance(id, str) and not id.isdigit():
|
|
18
13
|
raise ValueError(f"'id' must be a digit. Got '{id}'.")
|
|
19
14
|
|
|
20
15
|
self._session = session
|
|
21
|
-
self._id = str(id if id else self.create(**kwargs))
|
|
16
|
+
self._id = str(id if id else self.create(*args, **kwargs))
|
|
22
17
|
self.populate()
|
|
23
18
|
|
|
24
19
|
def __str__(self) -> str:
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from django.db import models
|
|
2
|
+
|
|
3
|
+
from terminusgps.wialon.items.base import WialonBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class WialonGeofence(WialonBase):
|
|
7
|
+
class WialonGeofenceShape(models.IntegerChoices):
|
|
8
|
+
LINE = 1
|
|
9
|
+
POLYGON = 2
|
|
10
|
+
CIRCLE = 3
|
|
11
|
+
|
|
12
|
+
class WialonGeofenceColor(models.IntegerChoices):
|
|
13
|
+
RED = int("ff0000", 16)
|
|
14
|
+
ORANGE = int("ff7b00", 16)
|
|
15
|
+
YELLOW = int("fffb00", 16)
|
|
16
|
+
GREEN = int("20ff00", 16)
|
|
17
|
+
BLUE = int("0090ff", 16)
|
|
18
|
+
PURPLE = int("7000ff", 16)
|
|
19
|
+
WHITE = int("f3f3f3", 16)
|
|
20
|
+
BLACK = int("030303", 16)
|
|
21
|
+
|
|
22
|
+
def create(
|
|
23
|
+
self,
|
|
24
|
+
resource_id: str | int,
|
|
25
|
+
name: str,
|
|
26
|
+
xpos: float,
|
|
27
|
+
ypos: float,
|
|
28
|
+
desc: str | None = None,
|
|
29
|
+
shape: int = WialonGeofenceShape.CIRCLE,
|
|
30
|
+
width: int = 100,
|
|
31
|
+
flags: int = 0x04,
|
|
32
|
+
color: int = WialonGeofenceColor.GREEN,
|
|
33
|
+
text_color: int = WialonGeofenceColor.BLACK,
|
|
34
|
+
text_size: int = 12,
|
|
35
|
+
min_zoom: int = 2,
|
|
36
|
+
max_zoom: int = 19,
|
|
37
|
+
) -> int | None:
|
|
38
|
+
response = self.session.wialon_api.resource_update_zone(
|
|
39
|
+
**{
|
|
40
|
+
"itemId": resource_id,
|
|
41
|
+
"id": 0,
|
|
42
|
+
"callMode": "create",
|
|
43
|
+
"n": name,
|
|
44
|
+
"d": desc if desc else name,
|
|
45
|
+
"t": shape,
|
|
46
|
+
"w": width,
|
|
47
|
+
"f": flags,
|
|
48
|
+
"c": color,
|
|
49
|
+
"tc": text_color,
|
|
50
|
+
"ts": text_size,
|
|
51
|
+
"min": min_zoom,
|
|
52
|
+
"max": max_zoom,
|
|
53
|
+
"p": [{"x": xpos, "y": ypos, "r": width}],
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
if response:
|
|
57
|
+
return int(response[0])
|
|
@@ -1,33 +1,4 @@
|
|
|
1
1
|
from terminusgps.wialon.items.base import WialonBase
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class WialonNotification(WialonBase):
|
|
5
|
-
def create(
|
|
6
|
-
self,
|
|
7
|
-
resource_id: str | int,
|
|
8
|
-
name: str,
|
|
9
|
-
activation_time: int,
|
|
10
|
-
deactivation_time: int,
|
|
11
|
-
text: str | None = None,
|
|
12
|
-
max_alarms: int = 0,
|
|
13
|
-
interval: int = 0,
|
|
14
|
-
lang: str = "en",
|
|
15
|
-
) -> int | None:
|
|
16
|
-
if isinstance(resource_id, str) and not resource_id.isdigit():
|
|
17
|
-
raise ValueError(f"'resource_id' must be a digit, got '{resource_id}'.")
|
|
18
|
-
|
|
19
|
-
response = self.session.wialon_api.resource_update_notification(
|
|
20
|
-
**{
|
|
21
|
-
"itemId": resource_id,
|
|
22
|
-
"id": 0,
|
|
23
|
-
"callMode": "create",
|
|
24
|
-
"n": name,
|
|
25
|
-
"txt": text if text else name,
|
|
26
|
-
"ta": activation_time,
|
|
27
|
-
"td": deactivation_time,
|
|
28
|
-
"ma": max_alarms,
|
|
29
|
-
"mmtd": interval,
|
|
30
|
-
"la": lang,
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
return int(response[0].get("id")) if response else None
|
|
4
|
+
class WialonNotification(WialonBase): ...
|
|
@@ -3,22 +3,31 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class WialonResource(WialonBase):
|
|
6
|
-
def create(self,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
def create(self, creator_id: str | int, name: str) -> int | None:
|
|
7
|
+
"""
|
|
8
|
+
Creates a new Wialon resource.
|
|
9
|
+
|
|
10
|
+
:param creator_id: A Wialon user id.
|
|
11
|
+
:type creator_id: :py:obj:`int` | :py:obj:`str`
|
|
12
|
+
:param name: A name for the resource.
|
|
13
|
+
:type name: :py:obj:`str`
|
|
14
|
+
:raises ValueError: If ``creator_id`` is not a digit.
|
|
15
|
+
:raises WialonError: If something goes wrong with Wialon.
|
|
16
|
+
:returns: The Wialon id for the new resource, if it was created.
|
|
17
|
+
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
21
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
13
22
|
|
|
14
23
|
response = self.session.wialon_api.core_create_resource(
|
|
15
24
|
**{
|
|
16
|
-
"creatorId":
|
|
17
|
-
"name":
|
|
18
|
-
"dataFlags":
|
|
25
|
+
"creatorId": creator_id,
|
|
26
|
+
"name": name,
|
|
27
|
+
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
19
28
|
}
|
|
20
29
|
)
|
|
21
|
-
return response.get("item", {}).get("id")
|
|
30
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
22
31
|
|
|
23
32
|
def delete(self) -> None:
|
|
24
33
|
"""
|
|
@@ -61,7 +70,7 @@ class WialonResource(WialonBase):
|
|
|
61
70
|
response = self.session.wialon_api.core_search_item(
|
|
62
71
|
**{"id": self.id, "flags": flags.DATAFLAG_RESOURCE_BILLING_PROPERTIES}
|
|
63
72
|
)
|
|
64
|
-
return response.get("item", {}).get("bact") == self.id
|
|
73
|
+
return int(response.get("item", {}).get("bact")) == self.id
|
|
65
74
|
|
|
66
75
|
def is_migrated(self, unit: WialonBase) -> bool:
|
|
67
76
|
"""
|
|
@@ -3,13 +3,13 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class WialonRetranslator(WialonBase):
|
|
6
|
-
def create(self,
|
|
6
|
+
def create(self, creator_id: str | int, name: str, config: dict) -> int | None:
|
|
7
7
|
"""
|
|
8
8
|
Creates a Wialon retranslator.
|
|
9
9
|
|
|
10
|
-
:param creator_id: A Wialon user
|
|
11
|
-
:type creator_id: :py:obj:`str`
|
|
12
|
-
:param name: A name for the
|
|
10
|
+
:param creator_id: A Wialon user id.
|
|
11
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
12
|
+
:param name: A name for the retranslator.
|
|
13
13
|
:type name: :py:obj:`str`
|
|
14
14
|
:param config: A Wialon retranslator configuration object.
|
|
15
15
|
:type config: :py:obj:`dict`
|
|
@@ -19,22 +19,18 @@ class WialonRetranslator(WialonBase):
|
|
|
19
19
|
:rtype: :py:obj:`None`
|
|
20
20
|
|
|
21
21
|
"""
|
|
22
|
-
if not
|
|
23
|
-
raise ValueError("'creator_id'
|
|
24
|
-
if not kwargs.get("name"):
|
|
25
|
-
raise ValueError("'name' is required on creation.")
|
|
26
|
-
if not kwargs.get("config"):
|
|
27
|
-
raise ValueError("'config' is required on creation.")
|
|
22
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
23
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
28
24
|
|
|
29
25
|
response = self.session.wialon_api.core_create_retranslator(
|
|
30
26
|
**{
|
|
31
|
-
"creatorId":
|
|
32
|
-
"name":
|
|
33
|
-
"config":
|
|
27
|
+
"creatorId": creator_id,
|
|
28
|
+
"name": name,
|
|
29
|
+
"config": config,
|
|
34
30
|
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
35
31
|
}
|
|
36
32
|
)
|
|
37
|
-
return response.get("item", {}).get("id")
|
|
33
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
38
34
|
|
|
39
35
|
def update_config(self, new_config: dict) -> None:
|
|
40
36
|
"""
|
|
@@ -3,19 +3,28 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class WialonRoute(WialonBase):
|
|
6
|
-
def create(self,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
def create(self, creator_id: str | int, name: str) -> int | None:
|
|
7
|
+
"""
|
|
8
|
+
Creates a new Wialon route.
|
|
9
|
+
|
|
10
|
+
:param creator_id: A Wialon user id.
|
|
11
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
12
|
+
:param name: A name for the route.
|
|
13
|
+
:type name: :py:obj:`str`
|
|
14
|
+
:raises ValueError: If ``creator_id`` is not a digit.
|
|
15
|
+
:raises WialonError: If something goes wrong with Wialon.
|
|
16
|
+
:returns: The Wialon id for the new route, if it was created.
|
|
17
|
+
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
21
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
13
22
|
|
|
14
23
|
response = self.session.wialon_api.core_create_route(
|
|
15
24
|
**{
|
|
16
|
-
"creatorId":
|
|
17
|
-
"name":
|
|
18
|
-
"dataFlags":
|
|
25
|
+
"creatorId": creator_id,
|
|
26
|
+
"name": name,
|
|
27
|
+
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
19
28
|
}
|
|
20
29
|
)
|
|
21
|
-
return response.get("item", {}).get("id")
|
|
30
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
terminusgps/wialon/items/unit.py
CHANGED
|
@@ -5,36 +5,36 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class WialonUnit(WialonBase):
|
|
8
|
-
def create(
|
|
8
|
+
def create(
|
|
9
|
+
self, creator_id: str | int, name: str, hw_type_id: str | int
|
|
10
|
+
) -> int | None:
|
|
9
11
|
"""
|
|
10
12
|
Creates a new Wialon unit.
|
|
11
13
|
|
|
12
14
|
:param creator_id: A Wialon user id.
|
|
13
|
-
:type creator_id: :py:obj:`int`
|
|
14
|
-
:param name: A
|
|
15
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
16
|
+
:param name: A name for the unit.
|
|
15
17
|
:type name: :py:obj:`str`
|
|
16
18
|
:param hw_type_id: A Wialon hardware type ID.
|
|
17
|
-
:type hw_type_id: :py:obj:`str`
|
|
19
|
+
:type hw_type_id: :py:obj:`str` | :py:obj:`int`
|
|
18
20
|
:returns: The Wialon id for the new unit.
|
|
19
21
|
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
20
22
|
|
|
21
23
|
"""
|
|
22
|
-
if not
|
|
23
|
-
raise ValueError("'creator_id'
|
|
24
|
-
if not
|
|
25
|
-
raise ValueError("'
|
|
26
|
-
if not kwargs.get("hw_type_id"):
|
|
27
|
-
raise ValueError("'hw_type_id' is required on creation.")
|
|
24
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
25
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
26
|
+
if isinstance(hw_type_id, str) and not hw_type_id.isdigit():
|
|
27
|
+
raise ValueError(f"'hw_type_id' must be a digit, got '{hw_type_id}'.")
|
|
28
28
|
|
|
29
29
|
response = self.session.wialon_api.core_create_unit(
|
|
30
30
|
**{
|
|
31
|
-
"creatorId":
|
|
32
|
-
"name":
|
|
33
|
-
"hwTypeId":
|
|
31
|
+
"creatorId": creator_id,
|
|
32
|
+
"name": name,
|
|
33
|
+
"hwTypeId": hw_type_id,
|
|
34
34
|
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
35
35
|
}
|
|
36
36
|
)
|
|
37
|
-
return response.get("item", {}).get("id")
|
|
37
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
38
38
|
|
|
39
39
|
@property
|
|
40
40
|
def available_commands(self) -> dict:
|
|
@@ -4,33 +4,32 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class WialonUnitGroup(WialonBase):
|
|
7
|
-
def create(self,
|
|
7
|
+
def create(self, creator_id: str | int, name: str) -> int | None:
|
|
8
8
|
"""
|
|
9
9
|
Creates a new Wialon unit group.
|
|
10
10
|
|
|
11
11
|
:param creator_id: A Wialon user id.
|
|
12
|
-
:type creator_id: :py:obj:`int`
|
|
12
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
13
13
|
:param name: A name for the group.
|
|
14
14
|
:type name: :py:obj:`str`
|
|
15
|
+
:raises ValueError: If ``creator_id`` is not a digit.
|
|
15
16
|
:raises WialonError: If something goes wrong with Wialon.
|
|
16
|
-
:returns: The Wialon id for the new group.
|
|
17
|
+
:returns: The Wialon id for the new group, if it was created.
|
|
17
18
|
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
18
19
|
|
|
19
20
|
"""
|
|
20
21
|
|
|
21
|
-
if not
|
|
22
|
-
raise ValueError("'creator_id'
|
|
23
|
-
if not kwargs.get("name"):
|
|
24
|
-
raise ValueError("'name' is required on creation.")
|
|
22
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
23
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
25
24
|
|
|
26
25
|
response = self.session.wialon_api.core_create_unit_group(
|
|
27
26
|
**{
|
|
28
|
-
"creatorId":
|
|
29
|
-
"name":
|
|
27
|
+
"creatorId": creator_id,
|
|
28
|
+
"name": name,
|
|
30
29
|
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
31
30
|
}
|
|
32
31
|
)
|
|
33
|
-
return response.get("item", {}).get("id")
|
|
32
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
34
33
|
|
|
35
34
|
def set_items(self, new_items: list[str]) -> None:
|
|
36
35
|
"""
|
terminusgps/wialon/items/user.py
CHANGED
|
@@ -5,37 +5,34 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class WialonUser(WialonBase):
|
|
8
|
-
def create(self,
|
|
8
|
+
def create(self, creator_id: str | int, name: str, password: str) -> int | None:
|
|
9
9
|
"""
|
|
10
10
|
Creates a new Wialon user.
|
|
11
11
|
|
|
12
12
|
:param creator_id: A Wialon user id.
|
|
13
|
-
:type creator_id: :py:obj:`int`
|
|
13
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
14
14
|
:param name: A name for the user.
|
|
15
15
|
:type name: :py:obj:`str`
|
|
16
|
-
:param
|
|
17
|
-
:type
|
|
16
|
+
:param password: A password for the user.
|
|
17
|
+
:type password: :py:obj:`str`
|
|
18
|
+
:raises ValueError: If ``creator_id`` is not a digit.
|
|
18
19
|
:raises WialonError: If something goes wrong with Wialon.
|
|
19
|
-
:returns: The Wialon id for the new user.
|
|
20
|
+
:returns: The Wialon id for the new user, if it was created.
|
|
20
21
|
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
21
22
|
|
|
22
23
|
"""
|
|
23
|
-
if not
|
|
24
|
-
raise ValueError("'creator_id'
|
|
25
|
-
if not kwargs.get("name"):
|
|
26
|
-
raise ValueError("'name' is required on creation.")
|
|
27
|
-
if not kwargs.get("password"):
|
|
28
|
-
raise ValueError("'password' is required on creation.")
|
|
24
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
25
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
29
26
|
|
|
30
27
|
response = self.session.wialon_api.core_create_user(
|
|
31
28
|
**{
|
|
32
|
-
"creatorId":
|
|
33
|
-
"name":
|
|
34
|
-
"password":
|
|
29
|
+
"creatorId": creator_id,
|
|
30
|
+
"name": name,
|
|
31
|
+
"password": password,
|
|
35
32
|
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
36
33
|
}
|
|
37
34
|
)
|
|
38
|
-
return response.get("item", {}).get("id")
|
|
35
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
39
36
|
|
|
40
37
|
def _get_access_response(self, hw_type: str) -> dict:
|
|
41
38
|
"""
|
terminusgps/wialon/session.py
CHANGED
|
@@ -367,16 +367,3 @@ class WialonSessionManager:
|
|
|
367
367
|
if not self._session:
|
|
368
368
|
self._session = WialonSession(sid=sid, log_level=log_level)
|
|
369
369
|
return self._session
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
def main() -> None:
|
|
373
|
-
from terminusgps.wialon.items import WialonUnit
|
|
374
|
-
|
|
375
|
-
with WialonSession(log_level=logging.DEBUG) as session:
|
|
376
|
-
unit = WialonUnit(id="28082258", session=session)
|
|
377
|
-
unit.add_cfield(("to_number", "+17133049421"))
|
|
378
|
-
return
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if __name__ == "__main__":
|
|
382
|
-
main()
|
terminusgps/wialon/utils.py
CHANGED
|
@@ -91,6 +91,29 @@ def get_wialon_cls(items_type: str) -> typing.Type[WialonBase]:
|
|
|
91
91
|
return wialon_cls
|
|
92
92
|
|
|
93
93
|
|
|
94
|
+
def get_vin_info(vin_number: str, session: WialonSession) -> dict:
|
|
95
|
+
"""
|
|
96
|
+
Retrieves vehicle data from a VIN number.
|
|
97
|
+
|
|
98
|
+
:param value: A vehicle's VIN number.
|
|
99
|
+
:type value: :py:obj:`str`
|
|
100
|
+
:param session: A valid Wialon API session.
|
|
101
|
+
:type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
|
|
102
|
+
:returns: A dictionary of vehicle information, if any was found.
|
|
103
|
+
:rtype: :py:obj:`dict`
|
|
104
|
+
|
|
105
|
+
"""
|
|
106
|
+
response = session.wialon_api.unit_get_vin_info(**{"vin": vin_number}).get(
|
|
107
|
+
"vin_lookup_result"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
{field.get("n"): field.get("v") for field in response.get("pflds")}
|
|
112
|
+
if "error" not in response.keys()
|
|
113
|
+
else {}
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
94
117
|
def is_unique(value: str, session: WialonSession, items_type: str = "avl_unit") -> bool:
|
|
95
118
|
"""
|
|
96
119
|
Determines if the value is unique among Wialon objects of type 'items_type'.
|
|
@@ -104,7 +127,6 @@ def is_unique(value: str, session: WialonSession, items_type: str = "avl_unit")
|
|
|
104
127
|
:returns: Whether or not the value is unique among 'items_type'.
|
|
105
128
|
:rtype: :py:obj:`bool`
|
|
106
129
|
|
|
107
|
-
|
|
108
130
|
"""
|
|
109
131
|
result = session.wialon_api.core_check_unique(
|
|
110
132
|
**{"type": items_type, "value": value.strip()}
|
|
@@ -173,13 +195,3 @@ def gen_wialon_password(length: int = 32) -> str:
|
|
|
173
195
|
stacklevel=2,
|
|
174
196
|
)
|
|
175
197
|
return generate_wialon_password(length)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
__all__ = [
|
|
179
|
-
"get_hw_type_id",
|
|
180
|
-
"get_id_from_iccid",
|
|
181
|
-
"get_wialon_cls",
|
|
182
|
-
"is_unique",
|
|
183
|
-
"generate_wialon_password",
|
|
184
|
-
"gen_wialon_password",
|
|
185
|
-
]
|
|
File without changes
|
{python_terminusgps-1.16.0.dist-info → python_terminusgps-1.18.0.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|