python-terminusgps 1.0.1__tar.gz → 1.0.2__tar.gz
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.0.1 → python_terminusgps-1.0.2}/PKG-INFO +1 -1
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/pyproject.toml +1 -1
- python_terminusgps-1.0.2/terminusgps/wialon/items/user.py +80 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/utils.py +3 -1
- python_terminusgps-1.0.1/terminusgps/wialon/items/user.py +0 -22
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/.gitignore +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/COPYING +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/README.md +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/requirements.txt +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/__init__.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/authorizenet/__init__.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/authorizenet/auth.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/__init__.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/constants.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/errors.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/flags.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/items/__init__.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/items/base.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/items/resource.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/items/retranslator.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/items/route.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/items/unit.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/items/unit_group.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/session.py +0 -0
- {python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: Provides abstractions/utilities for working with Wialon and Authorize.NET APIs.
|
|
5
5
|
Author-email: Blake Nall <blake@terminusgps.com>
|
|
6
6
|
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "python-terminusgps"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.2"
|
|
4
4
|
description = "Provides abstractions/utilities for working with Wialon and Authorize.NET APIs."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [ {name = "Blake Nall", email = "blake@terminusgps.com" } ]
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from urllib.parse import quote_plus
|
|
2
|
+
|
|
3
|
+
from terminusgps.wialon import flags
|
|
4
|
+
from terminusgps.wialon.items.base import WialonBase
|
|
5
|
+
from terminusgps.wialon import constants
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class WialonUser(WialonBase):
|
|
9
|
+
def create(self, **kwargs) -> int | None:
|
|
10
|
+
if not kwargs.get("owner_id"):
|
|
11
|
+
raise ValueError("'owner_id' is required on creation.")
|
|
12
|
+
if not kwargs.get("name"):
|
|
13
|
+
raise ValueError("'name' is required on creation.")
|
|
14
|
+
if not kwargs.get("password"):
|
|
15
|
+
raise ValueError("'password' is required on creation.")
|
|
16
|
+
|
|
17
|
+
response = self.session.wialon_api.core_create_user(
|
|
18
|
+
**{
|
|
19
|
+
"creatorId": kwargs["owner_id"],
|
|
20
|
+
"name": kwargs["name"],
|
|
21
|
+
"password": kwargs["password"],
|
|
22
|
+
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
return response.get("item", {}).get("id")
|
|
26
|
+
|
|
27
|
+
def _get_access_response(self, hw_type: str) -> dict:
|
|
28
|
+
return self.session.wialon_api.user_get_items_access(
|
|
29
|
+
**{
|
|
30
|
+
"userId": self.id,
|
|
31
|
+
"directAccess": True,
|
|
32
|
+
"itemSuperclass": hw_type,
|
|
33
|
+
"flags": 0x2,
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def units(self) -> list[str]:
|
|
39
|
+
response = self._get_access_response(hw_type="avl_unit")
|
|
40
|
+
return [key for key in response.keys()]
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def groups(self) -> list[str]:
|
|
44
|
+
response = self._get_access_response(hw_type="avl_unit_group")
|
|
45
|
+
return [key for key in response.keys()]
|
|
46
|
+
|
|
47
|
+
def has_access(self, other_item: WialonBase) -> bool:
|
|
48
|
+
response = self._get_access_response(hw_type=other_item.hw_type)
|
|
49
|
+
items = [key for key in response.keys()]
|
|
50
|
+
if str(other_item.id) in items:
|
|
51
|
+
return True
|
|
52
|
+
return False
|
|
53
|
+
|
|
54
|
+
def assign_phone(self, phone: str) -> None:
|
|
55
|
+
self.add_cproperty(("phone", quote_plus(phone)))
|
|
56
|
+
|
|
57
|
+
def assign_email(self, email: str) -> None:
|
|
58
|
+
self.add_cproperty(("email", email))
|
|
59
|
+
|
|
60
|
+
def assign_item(
|
|
61
|
+
self, item: WialonBase, access_mask: int = constants.ACCESSMASK_UNIT_BASIC
|
|
62
|
+
) -> None:
|
|
63
|
+
"""Assigns an item to this user according to the supplied access mask integer."""
|
|
64
|
+
self.session.wialon_api.user_update_item_access(
|
|
65
|
+
**{"userId": self.id, "itemId": item.id, "accessMask": access_mask}
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
def set_settings_flags(self, flags: int, flags_mask: int) -> None:
|
|
69
|
+
self.session.wialon_api.user_update_user_flags(
|
|
70
|
+
**{"userId": self.id, "flags": flags, "flagsMask": flags_mask}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
def update_password(self, old_password: str, new_password: str) -> None:
|
|
74
|
+
self.session.wialon_api.user_update_password(
|
|
75
|
+
**{
|
|
76
|
+
"userId": self.id,
|
|
77
|
+
"oldPassword": old_password,
|
|
78
|
+
"newPassword": new_password,
|
|
79
|
+
}
|
|
80
|
+
)
|
|
@@ -13,10 +13,12 @@ def is_unique(value: str, session: WialonSession, items_type: str = "avl_unit")
|
|
|
13
13
|
return not bool(result)
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
def gen_wialon_password(length: int =
|
|
16
|
+
def gen_wialon_password(length: int = 16) -> str:
|
|
17
17
|
"""Generates a Wialon compliant password."""
|
|
18
18
|
if length > 64:
|
|
19
19
|
raise ValueError(f"Passwords cannot be greater than 64 chars. Got '{length}'.")
|
|
20
|
+
if length < 4:
|
|
21
|
+
raise ValueError(f"Password cannot be less than 4 chars. Got '{length}'.")
|
|
20
22
|
|
|
21
23
|
symbols: str = "!@#$%^*()[]-_+"
|
|
22
24
|
alphabet: str = string.ascii_letters + string.digits + symbols
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from terminusgps.wialon import flags
|
|
2
|
-
from terminusgps.wialon.items.base import WialonBase
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class WialonUser(WialonBase):
|
|
6
|
-
def create(self, **kwargs) -> int | None:
|
|
7
|
-
if not kwargs.get("owner_id"):
|
|
8
|
-
raise ValueError("'owner_id' is required on creation.")
|
|
9
|
-
if not kwargs.get("name"):
|
|
10
|
-
raise ValueError("'name' is required on creation.")
|
|
11
|
-
if not kwargs.get("password"):
|
|
12
|
-
raise ValueError("'password' is required on creation.")
|
|
13
|
-
|
|
14
|
-
response = self.session.wialon_api.core_create_user(
|
|
15
|
-
**{
|
|
16
|
-
"creatorId": kwargs["owner_id"],
|
|
17
|
-
"name": kwargs["name"],
|
|
18
|
-
"password": kwargs["password"],
|
|
19
|
-
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
20
|
-
}
|
|
21
|
-
)
|
|
22
|
-
return response.get("item", {}).get("id")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/items/retranslator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_terminusgps-1.0.1 → python_terminusgps-1.0.2}/terminusgps/wialon/items/unit_group.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|