python-terminusgps 1.2.2__tar.gz → 1.4.0__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.

Potentially problematic release.


This version of python-terminusgps might be problematic. Click here for more details.

Files changed (28) hide show
  1. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/PKG-INFO +3 -2
  2. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/pyproject.toml +1 -1
  3. python_terminusgps-1.4.0/terminusgps/wialon/constants.py +76 -0
  4. python_terminusgps-1.4.0/terminusgps/wialon/items/account.py +25 -0
  5. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/items/base.py +0 -2
  6. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/items/resource.py +7 -5
  7. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/items/retranslator.py +3 -3
  8. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/items/route.py +6 -4
  9. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/items/unit.py +3 -3
  10. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/items/unit_group.py +14 -16
  11. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/items/user.py +3 -3
  12. python_terminusgps-1.2.2/terminusgps/wialon/constants.py +0 -39
  13. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/.gitignore +0 -0
  14. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/COPYING +0 -0
  15. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/README.md +0 -0
  16. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/requirements.txt +0 -0
  17. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/__init__.py +0 -0
  18. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/authorizenet/__init__.py +0 -0
  19. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/authorizenet/auth.py +0 -0
  20. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/aws/__init__.py +0 -0
  21. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/aws/secrets.py +0 -0
  22. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/__init__.py +0 -0
  23. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/errors.py +0 -0
  24. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/flags.py +0 -0
  25. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/items/__init__.py +0 -0
  26. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/session.py +0 -0
  27. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/terminusgps/wialon/utils.py +0 -0
  28. {python_terminusgps-1.2.2 → python_terminusgps-1.4.0}/uv.lock +0 -0
@@ -1,10 +1,11 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 1.2.2
3
+ Version: 1.4.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
7
7
  Author-email: Blake Nall <blake@terminusgps.com>
8
+ License-File: COPYING
8
9
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
9
10
  Classifier: Operating System :: OS Independent
10
11
  Classifier: Programming Language :: Python :: 3
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-terminusgps"
3
- version = "1.2.2"
3
+ version = "1.4.0"
4
4
  description = "Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more."
5
5
  readme = "README.md"
6
6
  authors = [ {name = "Blake Nall", email = "blake@terminusgps.com" } ]
@@ -0,0 +1,76 @@
1
+ from django.db import models
2
+ from django.utils.translation import gettext_lazy as _
3
+ from terminusgps.wialon import flags
4
+
5
+
6
+ class WialonCommandName(models.TextChoices):
7
+ SUB_BASIC = "Basic", _("Basic Subscription")
8
+ SUB_STANDARD = "Standard", _("Standard Subscription")
9
+ SUB_PREMIUM = "Premium", _("Premium Subscription")
10
+ STARTER_DISABLED = "Starter Disable On", _("Disable Starter")
11
+ STARTER_ENABLED = "Starter Disable Off", _("Enable Starter")
12
+ ENABLE = "On", _("Enable")
13
+ DISABLE = "Off", _("Disable")
14
+
15
+
16
+ class WialonCommandType(models.TextChoices):
17
+ ENGINE_BLOCK = "block_engine", _("Block Engine")
18
+ ENGINE_UNBLOCK = "unblock_engine", _("Unblock Engine")
19
+ CUSTOM_MSG = "custom_msg", _("Custom Message")
20
+ DRIVER_MSG = "driver_msg", _("Message to Driver")
21
+ DOWNLOAD_MSG = "download_msgs", _("Download messages")
22
+ QUERY_POS = "query_pos", _("Query Position")
23
+ QUERY_PHOTO = "query_photo", _("Query Snapshot")
24
+ OUTPUT_ON = "output_on", _("Activate Output")
25
+ OUTPUT_OFF = "output_off", _("Deactive Output")
26
+ SEND_POS = "send_position", _("Send Coordinates")
27
+ SET_REPORT_INT = "set_report_interval", _("Set Data Transfer Interval")
28
+ UPLOAD_CFG = "upload_cfg", _("Upload Configuration")
29
+ UPLOAD_SW = "upload_sw", _("Upload Firmware")
30
+
31
+
32
+ class WialonCommandLink(models.TextChoices):
33
+ AUTO = "", _("Auto")
34
+ TCP = "tcp", _("TCP")
35
+ UDP = "udp", _("UDP")
36
+ VRT = "vrt", _("Virtual")
37
+ GSM = "gsm", _("SMS")
38
+
39
+
40
+ ACCESSMASK_UNIT_BASIC: int = sum(
41
+ [
42
+ flags.ACCESSFLAG_VIEW_ITEM_BASIC,
43
+ flags.ACCESSFLAG_VIEW_ITEM_DETAILED,
44
+ flags.ACCESSFLAG_RENAME_ITEM,
45
+ flags.ACCESSFLAG_VIEW_CUSTOM_FIELDS,
46
+ flags.ACCESSFLAG_MANAGE_CUSTOM_FIELDS,
47
+ flags.ACCESSFLAG_MANAGE_ICON,
48
+ flags.ACCESSFLAG_QUERY_REPORTS,
49
+ flags.ACCESSFLAG_VIEW_ATTACHED_FILES,
50
+ flags.ACCESSFLAG_UNIT_EXECUTE_COMMANDS,
51
+ flags.ACCESSFLAG_UNIT_VIEW_SERVICE_INTERVALS,
52
+ flags.ACCESSFLAG_UNIT_REGISTER_EVENTS,
53
+ flags.ACCESSFLAG_UNIT_IMPORT_MESSAGES,
54
+ flags.ACCESSFLAG_UNIT_EXPORT_MESSAGES,
55
+ ]
56
+ )
57
+
58
+ ACCESSMASK_UNIT_SUPER: int = sum(
59
+ [
60
+ flags.ACCESSFLAG_VIEW_ITEM_BASIC,
61
+ flags.ACCESSFLAG_VIEW_ITEM_DETAILED,
62
+ flags.ACCESSFLAG_RENAME_ITEM,
63
+ flags.ACCESSFLAG_VIEW_CUSTOM_FIELDS,
64
+ flags.ACCESSFLAG_MANAGE_CUSTOM_FIELDS,
65
+ flags.ACCESSFLAG_MANAGE_ICON,
66
+ flags.ACCESSFLAG_QUERY_REPORTS,
67
+ flags.ACCESSFLAG_VIEW_ATTACHED_FILES,
68
+ flags.ACCESSFLAG_UNIT_EXECUTE_COMMANDS,
69
+ flags.ACCESSFLAG_UNIT_VIEW_SERVICE_INTERVALS,
70
+ flags.ACCESSFLAG_UNIT_REGISTER_EVENTS,
71
+ flags.ACCESSFLAG_UNIT_IMPORT_MESSAGES,
72
+ flags.ACCESSFLAG_UNIT_EXPORT_MESSAGES,
73
+ ]
74
+ )
75
+
76
+ ACCESSMASK_UNIT_FULL: int = sum([flags.ACCESSFLAG_FULL_ACCESS])
@@ -0,0 +1,25 @@
1
+ from terminusgps.wialon.items.base import WialonBase
2
+ from terminusgps.wialon.items import WialonResource, WialonUser
3
+
4
+
5
+ class WialonAccount(WialonBase):
6
+ def __init__(
7
+ self, billing_plan: str = "terminusgps_ext_hist", *args, **kwargs
8
+ ) -> None:
9
+ super().__init__(*args, **kwargs)
10
+ self.billing_plan = billing_plan
11
+
12
+ def create(self, **kwargs) -> int | None:
13
+ if not kwargs.get("creator_id"):
14
+ raise ValueError("'creator_id' is required for creation.")
15
+
16
+ user = WialonUser(id=str(kwargs["creator_id"]), session=self.session)
17
+ resource = WialonResource(
18
+ creator_id=kwargs["creator_id"],
19
+ name=f"super_{user.name}",
20
+ session=self.session,
21
+ )
22
+ self.session.wialon_api.account_create_account(
23
+ **{"itemId": resource.id, "plan": kwargs.get("plan", self.billing_plan)}
24
+ )
25
+ return int(kwargs["resource_id"])
@@ -1,5 +1,3 @@
1
- from typing import Any
2
-
3
1
  import terminusgps.wialon.flags as flags
4
2
  from terminusgps.wialon.session import WialonSession
5
3
  from terminusgps.wialon.utils import repopulate
@@ -4,16 +4,18 @@ from terminusgps.wialon.items.base import WialonBase
4
4
 
5
5
  class WialonResource(WialonBase):
6
6
  def create(self, **kwargs) -> int | None:
7
- if not kwargs.get("owner_id"):
8
- raise ValueError("'owner_id' is required on creation.")
7
+ if not kwargs.get("creator_id"):
8
+ raise ValueError("'creator_id' is required for creation.")
9
9
  if not kwargs.get("name"):
10
- raise ValueError("'name' is required on creation.")
10
+ raise ValueError("'name' is required for creation.")
11
+ if not kwargs.get("flags"):
12
+ kwargs["flags"] = flags.DATAFLAG_UNIT_BASE
11
13
 
12
14
  response = self.session.wialon_api.core_create_resource(
13
15
  **{
14
- "creatorId": kwargs["owner_id"],
16
+ "creatorId": kwargs["creator_id"],
15
17
  "name": kwargs["name"],
16
- "dataFlags": flags.DATAFLAG_UNIT_BASE,
18
+ "dataFlags": kwargs["flags"],
17
19
  "skipCreatorCheck": True,
18
20
  }
19
21
  )
@@ -4,8 +4,8 @@ from terminusgps.wialon.items.base import WialonBase
4
4
 
5
5
  class WialonRetranslator(WialonBase):
6
6
  def create(self, **kwargs) -> int | None:
7
- if not kwargs.get("owner_id"):
8
- raise ValueError("'owner_id' is required on creation.")
7
+ if not kwargs.get("creator_id"):
8
+ raise ValueError("'creator_id' is required on creation.")
9
9
  if not kwargs.get("name"):
10
10
  raise ValueError("'name' is required on creation.")
11
11
  if not kwargs.get("config"):
@@ -13,7 +13,7 @@ class WialonRetranslator(WialonBase):
13
13
 
14
14
  response = self.session.wialon_api.core_create_retranslator(
15
15
  **{
16
- "creatorId": kwargs["owner_id"],
16
+ "creatorId": kwargs["creator_id"],
17
17
  "name": kwargs["name"],
18
18
  "config": kwargs["config"],
19
19
  "dataFlags": flags.DATAFLAG_UNIT_BASE,
@@ -4,16 +4,18 @@ from terminusgps.wialon.items.base import WialonBase
4
4
 
5
5
  class WialonRoute(WialonBase):
6
6
  def create(self, **kwargs) -> int | None:
7
- if not kwargs.get("owner_id"):
8
- raise ValueError("'owner_id' is required on creation.")
7
+ if not kwargs.get("creator_id"):
8
+ raise ValueError("'creator_id' is required on creation.")
9
9
  if not kwargs.get("name"):
10
10
  raise ValueError("'name' is required on creation.")
11
+ if not kwargs.get("flags"):
12
+ kwargs["flags"] = flags.DATAFLAG_UNIT_BASE
11
13
 
12
14
  response = self.session.wialon_api.core_create_route(
13
15
  **{
14
- "creatorId": kwargs["owner_id"],
16
+ "creatorId": kwargs["creator_id"],
15
17
  "name": kwargs["name"],
16
- "dataFlags": flags.DATAFLAG_UNIT_BASE,
18
+ "dataFlags": kwargs["flags"],
17
19
  }
18
20
  )
19
21
  return response.get("item", {}).get("id")
@@ -6,8 +6,8 @@ from terminusgps.wialon.items.base import WialonBase, repopulate
6
6
 
7
7
  class WialonUnit(WialonBase):
8
8
  def create(self, **kwargs) -> int | None:
9
- if not kwargs.get("owner_id"):
10
- raise ValueError("'owner_id' is required on creation.")
9
+ if not kwargs.get("creator_id"):
10
+ raise ValueError("'creator_id' is required on creation.")
11
11
  if not kwargs.get("name"):
12
12
  raise ValueError("'name' is required on creation.")
13
13
  if not kwargs.get("hw_type"):
@@ -15,7 +15,7 @@ class WialonUnit(WialonBase):
15
15
 
16
16
  response = self.session.wialon_api.core_create_unit(
17
17
  **{
18
- "creatorId": kwargs["owner_id"],
18
+ "creatorId": kwargs["creator_id"],
19
19
  "name": kwargs["name"],
20
20
  "hwTypeId": kwargs["hw_type"],
21
21
  "dataFlags": flags.DATAFLAG_UNIT_BASE,
@@ -3,33 +3,32 @@ from terminusgps.wialon.items.base import WialonBase
3
3
 
4
4
 
5
5
  class WialonUnitGroup(WialonBase):
6
- def _update_items(self, new_items: list[str]) -> None:
7
- self.session.wialon_api.unit_group_update_units(
8
- **{"itemId": self.id, "units": new_items}
9
- )
10
-
11
6
  def create(self, **kwargs) -> int | None:
12
- if not kwargs.get("owner_id"):
13
- raise ValueError("'owner_id' is required on creation.")
7
+ if not kwargs.get("creator_id"):
8
+ raise ValueError("'creator_id' is required on creation.")
14
9
  if not kwargs.get("name"):
15
10
  raise ValueError("'name' is required on creation.")
16
11
 
17
12
  response = self.session.wialon_api.core_create_unit_group(
18
13
  **{
19
- "creatorId": kwargs["owner_id"],
14
+ "creatorId": kwargs["creator_id"],
20
15
  "name": kwargs["name"],
21
16
  "dataFlags": flags.DATAFLAG_UNIT_BASE,
22
17
  }
23
18
  )
24
19
  return response.get("item", {}).get("id")
25
20
 
21
+ def _update_items(self, new_items: list[str]) -> None:
22
+ self.session.wialon_api.unit_group_update_units(
23
+ **{"itemId": self.id, "units": new_items}
24
+ )
25
+
26
26
  def is_member(self, item: WialonBase) -> bool:
27
27
  return True if str(item.id) in self.items else False
28
28
 
29
- def grant_access(self, item: WialonBase, access_mask: int | None = None) -> None:
30
- if not access_mask:
31
- access_mask = constants.ACCESSMASK_UNIT_BASIC
32
-
29
+ def grant_access(
30
+ self, item: WialonBase, access_mask: int = constants.ACCESSMASK_UNIT_BASIC
31
+ ) -> None:
33
32
  self.session.wialon_api.user_update_item_access(
34
33
  **{"userId": item.id, "itemId": self.id, "accessMask": access_mask}
35
34
  )
@@ -40,18 +39,17 @@ class WialonUnitGroup(WialonBase):
40
39
  )
41
40
 
42
41
  def add_item(self, item: WialonBase) -> None:
43
- new_items: list[str] = self.items + [str(item.id)]
42
+ new_items: list[str] = self.items.copy() + [str(item.id)]
44
43
  self._update_items(new_items)
45
44
 
46
45
  def rm_item(self, item: WialonBase) -> None:
47
- assert self.is_member(item), "Cannot remove item, it's not in the group"
48
- new_items: list[str] = self.items
46
+ assert self.is_member(item), f"Cannot remove {item.name}, it's not in the group"
47
+ new_items: list[str] = self.items.copy()
49
48
  new_items.remove(str(item.id))
50
49
  self._update_items(new_items)
51
50
 
52
51
  @property
53
52
  def items(self) -> list[str]:
54
- """Calls the Wialon API and returns a list of group member IDs."""
55
53
  response = self.session.wialon_api.core_search_items(
56
54
  **{
57
55
  "spec": {
@@ -7,8 +7,8 @@ from terminusgps.wialon import constants
7
7
 
8
8
  class WialonUser(WialonBase):
9
9
  def create(self, **kwargs) -> int | None:
10
- if not kwargs.get("owner_id"):
11
- raise ValueError("'owner_id' is required on creation.")
10
+ if not kwargs.get("creator_id"):
11
+ raise ValueError("'creator_id' is required on creation.")
12
12
  if not kwargs.get("name"):
13
13
  raise ValueError("'name' is required on creation.")
14
14
  if not kwargs.get("password"):
@@ -16,7 +16,7 @@ class WialonUser(WialonBase):
16
16
 
17
17
  response = self.session.wialon_api.core_create_user(
18
18
  **{
19
- "creatorId": kwargs["owner_id"],
19
+ "creatorId": kwargs["creator_id"],
20
20
  "name": kwargs["name"],
21
21
  "password": kwargs["password"],
22
22
  "dataFlags": flags.DATAFLAG_UNIT_BASE,
@@ -1,39 +0,0 @@
1
- from terminusgps.wialon import flags
2
-
3
- ACCESSMASK_UNIT_BASIC: int = sum(
4
- [
5
- flags.ACCESSFLAG_VIEW_ITEM_BASIC,
6
- flags.ACCESSFLAG_VIEW_ITEM_DETAILED,
7
- flags.ACCESSFLAG_RENAME_ITEM,
8
- flags.ACCESSFLAG_VIEW_CUSTOM_FIELDS,
9
- flags.ACCESSFLAG_MANAGE_CUSTOM_FIELDS,
10
- flags.ACCESSFLAG_MANAGE_ICON,
11
- flags.ACCESSFLAG_QUERY_REPORTS,
12
- flags.ACCESSFLAG_VIEW_ATTACHED_FILES,
13
- flags.ACCESSFLAG_UNIT_EXECUTE_COMMANDS,
14
- flags.ACCESSFLAG_UNIT_VIEW_SERVICE_INTERVALS,
15
- flags.ACCESSFLAG_UNIT_REGISTER_EVENTS,
16
- flags.ACCESSFLAG_UNIT_IMPORT_MESSAGES,
17
- flags.ACCESSFLAG_UNIT_EXPORT_MESSAGES,
18
- ]
19
- )
20
-
21
- ACCESSMASK_UNIT_SUPER: int = sum(
22
- [
23
- flags.ACCESSFLAG_VIEW_ITEM_BASIC,
24
- flags.ACCESSFLAG_VIEW_ITEM_DETAILED,
25
- flags.ACCESSFLAG_RENAME_ITEM,
26
- flags.ACCESSFLAG_VIEW_CUSTOM_FIELDS,
27
- flags.ACCESSFLAG_MANAGE_CUSTOM_FIELDS,
28
- flags.ACCESSFLAG_MANAGE_ICON,
29
- flags.ACCESSFLAG_QUERY_REPORTS,
30
- flags.ACCESSFLAG_VIEW_ATTACHED_FILES,
31
- flags.ACCESSFLAG_UNIT_EXECUTE_COMMANDS,
32
- flags.ACCESSFLAG_UNIT_VIEW_SERVICE_INTERVALS,
33
- flags.ACCESSFLAG_UNIT_REGISTER_EVENTS,
34
- flags.ACCESSFLAG_UNIT_IMPORT_MESSAGES,
35
- flags.ACCESSFLAG_UNIT_EXPORT_MESSAGES,
36
- ]
37
- )
38
-
39
- ACCESSMASK_UNIT_FULL: int = sum([flags.ACCESSFLAG_FULL_ACCESS])