python-terminusgps 47.3.3__tar.gz → 48.0.1__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.
Files changed (54) hide show
  1. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/PKG-INFO +1 -1
  2. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/conf.py +1 -1
  3. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/pyproject.toml +1 -1
  4. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/mixins.py +3 -3
  5. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/base.py +1 -1
  6. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/session.py +8 -5
  7. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/utils.py +124 -0
  8. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/uv.lock +4 -4
  9. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/.github/workflows/sphinx.yml +0 -0
  10. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/.gitignore +0 -0
  11. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/.python-version +0 -0
  12. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/COPYING +0 -0
  13. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/README.md +0 -0
  14. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/Makefile +0 -0
  15. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/make.bat +0 -0
  16. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/requirements.txt +0 -0
  17. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/authorizenet/api.rst +0 -0
  18. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/authorizenet/constants.rst +0 -0
  19. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/authorizenet/index.rst +0 -0
  20. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/authorizenet/service.rst +0 -0
  21. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/index.rst +0 -0
  22. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/mixins.rst +0 -0
  23. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/validators.rst +0 -0
  24. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/wialon/constants.rst +0 -0
  25. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/wialon/exceptions.rst +0 -0
  26. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/wialon/index.rst +0 -0
  27. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/wialon/items.rst +0 -0
  28. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/wialon/session.rst +0 -0
  29. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/wialon/usage.rst +0 -0
  30. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/docs/source/wialon/utils.rst +0 -0
  31. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/__init__.py +0 -0
  32. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/authorizenet/__init__.py +0 -0
  33. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/authorizenet/api/__init__.py +0 -0
  34. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/authorizenet/api/address_profiles.py +0 -0
  35. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/authorizenet/api/customer_profiles.py +0 -0
  36. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/authorizenet/api/payment_profiles.py +0 -0
  37. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/authorizenet/api/subscriptions.py +0 -0
  38. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/authorizenet/api/transactions.py +0 -0
  39. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/authorizenet/constants.py +0 -0
  40. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/authorizenet/service.py +0 -0
  41. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/default_settings.py +0 -0
  42. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/validators.py +0 -0
  43. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/__init__.py +0 -0
  44. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/constants.py +0 -0
  45. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/flags.py +0 -0
  46. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/__init__.py +0 -0
  47. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/account.py +0 -0
  48. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/factory.py +0 -0
  49. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/resource.py +0 -0
  50. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/retranslator.py +0 -0
  51. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/route.py +0 -0
  52. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/unit.py +0 -0
  53. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/unit_group.py +0 -0
  54. {python_terminusgps-47.3.3 → python_terminusgps-48.0.1}/terminusgps/wialon/items/user.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 47.3.3
3
+ Version: 48.0.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://terminusgps.github.io/python-terminusgps
6
6
  Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
@@ -12,7 +12,7 @@ sys.path.insert(0, os.path.abspath("../../"))
12
12
  project = "python-terminusgps"
13
13
  copyright = "2025, Terminus GPS, LLC"
14
14
  author = "Terminus GPS, LLC"
15
- release = "47.3.3"
15
+ release = "48.0.1"
16
16
 
17
17
  # -- General configuration ---------------------------------------------------
18
18
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-terminusgps"
3
- version = "47.3.3"
3
+ version = "48.0.1"
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" } ]
@@ -16,15 +16,15 @@ class HtmxTemplateResponseMixin(TemplateResponseMixin):
16
16
  """
17
17
  A partial template rendered by htmx.
18
18
 
19
- :type: :py:obj:`str` | :py:obj:`None`
20
- :value: :py:obj:`None`
19
+ :type: str | None
20
+ :value: None
21
21
 
22
22
  """
23
23
 
24
24
  def render_to_response(
25
25
  self, context: dict[str, typing.Any], **response_kwargs: typing.Any
26
26
  ) -> HttpResponse:
27
- """Sets :py:attr:`template_name` to :py:attr:`partial_template_name` if necessary."""
27
+ """Sets :py:attr:`template_name` to :py:attr:`partial_template_name` according to request headers."""
28
28
  htmx_request = self.request.headers.get("HX-Request", False)
29
29
  boosted = self.request.headers.get("HX-Boosted", False)
30
30
 
@@ -83,7 +83,7 @@ class WialonObject(ABC):
83
83
 
84
84
  @requires_id
85
85
  def get_name(self) -> str:
86
- """Gets and returns the object's name from Wialon."""
86
+ """Returns the object's name from Wialon."""
87
87
  return str(
88
88
  self.session.wialon_api.core_search_item(
89
89
  **{"id": self.id, "flags": 1}
@@ -12,8 +12,12 @@ class WialonAPIError(Exception):
12
12
 
13
13
  def __init__(self, message, *args, **kwargs) -> None:
14
14
  self.message = message
15
- self._code = int(message._code)
16
- super().__init__(message, *args, **kwargs)
15
+ try:
16
+ self._code = int(message._code)
17
+ except ValueError:
18
+ # 6 = 'Unknown Error' according to Wialon
19
+ self._code = 6
20
+ return super().__init__(message, *args, **kwargs)
17
21
 
18
22
  @property
19
23
  def code(self) -> int:
@@ -57,7 +61,7 @@ class WialonSession:
57
61
  :type token: str | None
58
62
  :param auth_hash: A Wialon API authentication hash. Default is :py:obj:`None`.
59
63
  :type auth_hash: str | None
60
- :param username: A Wialon user to operate as during the session. Default is environment variable ``"WIALON_USERNAME"``.
64
+ :param username: A Wialon user to operate as during the session.
61
65
  :type username: str | None
62
66
  :param check_service: A Wialon service name to check before calling the Wialon API. Default is :py:obj:`None`.
63
67
  :type check_service: str | None
@@ -67,9 +71,8 @@ class WialonSession:
67
71
  """
68
72
  self._uid = None
69
73
  self._wialon_api = Wialon(scheme=scheme, host=host, port=port, sid=sid)
70
-
71
74
  self._token = token if token else os.getenv("WIALON_TOKEN")
72
- self._username = username if username else os.getenv("WIALON_USERNAME")
75
+ self._username = username
73
76
  self._auth_hash = auth_hash
74
77
  self._check_service = check_service
75
78
 
@@ -1,6 +1,7 @@
1
1
  import secrets
2
2
  import string
3
3
  import typing
4
+ from collections.abc import Collection
4
5
 
5
6
  from terminusgps.wialon import flags
6
7
  from terminusgps.wialon.items import WialonObjectFactory
@@ -9,6 +10,129 @@ from terminusgps.wialon.items.user import WialonUser
9
10
  from terminusgps.wialon.session import WialonSession
10
11
 
11
12
 
13
+ def get_notifications(
14
+ resource_id: str | int,
15
+ session: WialonSession,
16
+ notification_ids: Collection[int] | None = None,
17
+ ) -> list[dict[str, typing.Any]]:
18
+ """
19
+ Returns a list of notification dictionaries from the Wialon API.
20
+
21
+ Wialon notification dictionary format:
22
+
23
+ +----------------+----------------+-----------------------------------------------+
24
+ | key | type | desc |
25
+ +================+================+===============================================+
26
+ | ``"id"`` | :py:obj:`int` | Notification ID |
27
+ +----------------+----------------+-----------------------------------------------+
28
+ | ``"n"`` | :py:obj:`str` | Notification name |
29
+ +----------------+----------------+-----------------------------------------------+
30
+ | ``"txt"`` | :py:obj:`int` | Notification text |
31
+ +----------------+----------------+-----------------------------------------------+
32
+ | ``"ta"`` | :py:obj:`int` | Activation time (UNIX timestamp) |
33
+ +----------------+----------------+-----------------------------------------------+
34
+ | ``"td"`` | :py:obj:`int` | Deactivation time (UNIX timestamp) |
35
+ +----------------+----------------+-----------------------------------------------+
36
+ | ``"ma"`` | :py:obj:`int` | Maximum number of alarms (0 = unlimited) |
37
+ +----------------+----------------+-----------------------------------------------+
38
+ | ``"mmtd"`` | :py:obj:`int` | Maximum time interval between messages (sec) |
39
+ +----------------+----------------+-----------------------------------------------+
40
+ | ``"cdt"`` | :py:obj:`int` | Alarm timeout (sec) |
41
+ +----------------+----------------+-----------------------------------------------+
42
+ | ``"mast"`` | :py:obj:`int` | Minimum duration of the alarm state (sec) |
43
+ +----------------+----------------+-----------------------------------------------+
44
+ | ``"mpst"`` | :py:obj:`int` | Minimum duration of previous state (sec) |
45
+ +----------------+----------------+-----------------------------------------------+
46
+ | ``"cp"`` | :py:obj:`int` | Control period relative to current time (sec) |
47
+ +----------------+----------------+-----------------------------------------------+
48
+ | ``"fl"`` | :py:obj:`int` | Notification flags |
49
+ +----------------+----------------+-----------------------------------------------+
50
+ | ``"tz"`` | :py:obj:`int` | Notification timezone |
51
+ +----------------+----------------+-----------------------------------------------+
52
+ | ``"la"`` | :py:obj:`str` | Notification language code |
53
+ +----------------+----------------+-----------------------------------------------+
54
+ | ``"ac"`` | :py:obj:`int` | Alarms count |
55
+ +----------------+----------------+-----------------------------------------------+
56
+ | ``"d"`` | :py:obj:`str` | Notification description |
57
+ +----------------+----------------+-----------------------------------------------+
58
+ | ``"sch"`` | :py:obj:`dict` | Notification schedule (see below) |
59
+ +----------------+----------------+-----------------------------------------------+
60
+ | ``"ctrl_sch"`` | :py:obj:`dict` | Notification control schedule (see below) |
61
+ +----------------+----------------+-----------------------------------------------+
62
+ | ``"un"`` | :py:obj:`list` | List of unit/unit group IDs |
63
+ +----------------+----------------+-----------------------------------------------+
64
+ | ``"act"`` | :py:obj:`list` | List of notification actions (see below) |
65
+ +----------------+----------------+-----------------------------------------------+
66
+ | ``"trg"`` | :py:obj:`dict` | Notification trigger (see below) |
67
+ +----------------+----------------+-----------------------------------------------+
68
+ | ``"ct"`` | :py:obj:`int` | Creation time (UNIX timestamp) |
69
+ +----------------+----------------+-----------------------------------------------+
70
+ | ``"mt"`` | :py:obj:`int` | Last modification time (UNIX timestamp) |
71
+ +----------------+----------------+-----------------------------------------------+
72
+
73
+ Notification schedule/control schedule format:
74
+
75
+ +----------+----------------+------------------------------------------------------------------+
76
+ | key | type | desc |
77
+ +==========+================+==================================================================+
78
+ | ``"f1"`` | :py:obj:`int` | Beginning of interval 1 (minutes from midnight) |
79
+ +----------+----------------+------------------------------------------------------------------+
80
+ | ``"f2"`` | :py:obj:`int` | Beginning of interval 2 (minutes from midnight) |
81
+ +----------+----------------+------------------------------------------------------------------+
82
+ | ``"t1"`` | :py:obj:`int` | End of interval 1 (minutes from midnight) |
83
+ +----------+----------------+------------------------------------------------------------------+
84
+ | ``"t2"`` | :py:obj:`int` | End of interval 2 (minutes from midnight) |
85
+ +----------+----------------+------------------------------------------------------------------+
86
+ | ``"m"`` | :py:obj:`int` | Mask of the days of the month (1: 2\ :sup:`0`, 31: 2\ :sup:`30`) |
87
+ +----------+----------------+------------------------------------------------------------------+
88
+ | ``"y"`` | :py:obj:`int` | Mask of months (Jan: 2\ :sup:`0`, Dec: 2\ :sup:`11`) |
89
+ +----------+----------------+------------------------------------------------------------------+
90
+ | ``"w"`` | :py:obj:`int` | Mask of days of the week (Mon: 2\ :sup:`0`, Sun: 2\ :sup:`6`) |
91
+ +----------+----------------+------------------------------------------------------------------+
92
+ | ``"f"`` | :py:obj:`int` | Schedule flags |
93
+ +----------+----------------+------------------------------------------------------------------+
94
+
95
+ Notification `action <https://wialon-help.link/bb04a9a5>`_ format (each item in the ``act`` list):
96
+
97
+ +----------+-----------------+-------------------+
98
+ | key | type | desc |
99
+ +==========+=================+===================+
100
+ | ``"t"`` | :py:obj:`str` | Action type |
101
+ +----------+-----------------+-------------------+
102
+ | ``"p"`` | :py:obj:`dict` | Action parameters |
103
+ +----------+-----------------+-------------------+
104
+
105
+ Notification `trigger <https://wialon-help.link/9d54585d>`_ format:
106
+
107
+ +----------+-----------------+--------------------+
108
+ | key | type | desc |
109
+ +==========+=================+====================+
110
+ | ``"t"`` | :py:obj:`str` | Trigger type |
111
+ +----------+-----------------+--------------------+
112
+ | ``"p"`` | :py:obj:`dict` | Trigger parameters |
113
+ +----------+-----------------+--------------------+
114
+
115
+ :param resource_id: A Wialon resource id.
116
+ :type resource_id: str | int
117
+ :param session: A valid Wialon API session.
118
+ :type session: ~terminusgps.wialon.session.WialonSession
119
+ :param notification_ids: Optional. A list of notification ids.
120
+ :type notification_ids: ~collections.abc.Collection[int] | None
121
+ :raises ValueError: If ``resource_id`` was a string containing non-digit characters.
122
+ :returns: A list of Wialon notification dictionaries.
123
+ :rtype: list[dict[str, ~typing.Any]]
124
+
125
+ """
126
+ if isinstance(resource_id, str) and not resource_id.isdigit():
127
+ raise ValueError(
128
+ f"resource_id can only contain digits, got '{resource_id}'."
129
+ )
130
+ params = {"itemId": resource_id}
131
+ if notification_ids is not None:
132
+ params["col"] = notification_ids
133
+ return session.wialon_api.resource_get_notification_data(**params)
134
+
135
+
12
136
  def get_hw_types(session: WialonSession) -> list[dict[str, str | int]]:
13
137
  """
14
138
  Returns a list of hardware type objects for Wialon.
@@ -143,16 +143,16 @@ wheels = [
143
143
 
144
144
  [[package]]
145
145
  name = "django"
146
- version = "5.2.7"
146
+ version = "5.2.8"
147
147
  source = { registry = "https://pypi.org/simple" }
148
148
  dependencies = [
149
149
  { name = "asgiref" },
150
150
  { name = "sqlparse" },
151
151
  { name = "tzdata", marker = "sys_platform == 'win32'" },
152
152
  ]
153
- sdist = { url = "https://files.pythonhosted.org/packages/b1/96/bd84e2bb997994de8bcda47ae4560991084e86536541d7214393880f01a8/django-5.2.7.tar.gz", hash = "sha256:e0f6f12e2551b1716a95a63a1366ca91bbcd7be059862c1b18f989b1da356cdd", size = 10865812 }
153
+ sdist = { url = "https://files.pythonhosted.org/packages/05/a2/933dbbb3dd9990494960f6e64aca2af4c0745b63b7113f59a822df92329e/django-5.2.8.tar.gz", hash = "sha256:23254866a5bb9a2cfa6004e8b809ec6246eba4b58a7589bc2772f1bcc8456c7f", size = 10849032 }
154
154
  wheels = [
155
- { url = "https://files.pythonhosted.org/packages/8f/ef/81f3372b5dd35d8d354321155d1a38894b2b766f576d0abffac4d8ae78d9/django-5.2.7-py3-none-any.whl", hash = "sha256:59a13a6515f787dec9d97a0438cd2efac78c8aca1c80025244b0fe507fe0754b", size = 8307145 },
155
+ { url = "https://files.pythonhosted.org/packages/5e/3d/a035a4ee9b1d4d4beee2ae6e8e12fe6dee5514b21f62504e22efcbd9fb46/django-5.2.8-py3-none-any.whl", hash = "sha256:37e687f7bd73ddf043e2b6b97cfe02fcbb11f2dbb3adccc6a2b18c6daa054d7f", size = 8289692 },
156
156
  ]
157
157
 
158
158
  [[package]]
@@ -338,7 +338,7 @@ wheels = [
338
338
 
339
339
  [[package]]
340
340
  name = "python-terminusgps"
341
- version = "47.3.3"
341
+ version = "48.0.1"
342
342
  source = { editable = "." }
343
343
  dependencies = [
344
344
  { name = "authorizenet" },