python-terminusgps 41.0.1__py3-none-any.whl → 41.2.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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 41.0.1
3
+ Version: 41.2.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://docs.terminusgps.com
6
6
  Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
@@ -22,6 +22,7 @@ terminusgps/django/forms/renderer.py,sha256=QSLQ94Ff7ZaV1jD6wAL-ltvdKIblED8Wsv5E
22
22
  terminusgps/django/forms/widgets.py,sha256=No4hPQ-BK5rrotaQ5iJEjWo8quYIPNf_1C2y4OAIxro,2037
23
23
  terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  terminusgps/wialon/constants.py,sha256=p2BhopeE6lXzjzdzb4ZKOz0rhJQIMUbXLrBy1Yzf57s,13730
25
+ terminusgps/wialon/factory.py,sha256=owo2vak98XvMDhKevDE20pld2-IXZk2VtTkaHmth-6k,2013
25
26
  terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
26
27
  terminusgps/wialon/session.py,sha256=jQbPmQy6z7ghhgflRemybn8_uoCnCJzuTcbovLHFpI4,5795
27
28
  terminusgps/wialon/utils.py,sha256=GH1l9IgO2cAp2_lI3K3R6MDy3BlFUiOQF4YFzqMx8l4,8891
@@ -35,7 +36,7 @@ terminusgps/wialon/items/route.py,sha256=xixlex6bUeFHXucVQdbfQUSLxI1Rhwk6slhoFP2
35
36
  terminusgps/wialon/items/unit.py,sha256=kfiqysdPxiU_8fHomKZEz3Ypbkaoc5HevOzpqr7R7rI,5189
36
37
  terminusgps/wialon/items/unit_group.py,sha256=L7-PAVCj8Bf50fa04Ials4VHg8LOWkw6hwNhtSyMksE,2133
37
38
  terminusgps/wialon/items/user.py,sha256=hZlFeXCgOAdivl_Anjp_We6Cy5U8IxWNDAgm5MFZfp0,5194
38
- python_terminusgps-41.0.1.dist-info/METADATA,sha256=PAD08KI7bPW2nNpxQL59gR3Gd6iVmwgR7Ev6lzd9H6M,976
39
- python_terminusgps-41.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
40
- python_terminusgps-41.0.1.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
41
- python_terminusgps-41.0.1.dist-info/RECORD,,
39
+ python_terminusgps-41.2.0.dist-info/METADATA,sha256=xhBTSSSzCvaeC0HHM-S9Pbg-H95jRJQL1_8gbajdg9c,976
40
+ python_terminusgps-41.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
+ python_terminusgps-41.2.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
42
+ python_terminusgps-41.2.0.dist-info/RECORD,,
@@ -0,0 +1,60 @@
1
+ from terminusgps.wialon.items import (
2
+ WialonAccount,
3
+ WialonResource,
4
+ WialonRetranslator,
5
+ WialonRoute,
6
+ WialonUnit,
7
+ WialonUnitGroup,
8
+ WialonUser,
9
+ )
10
+ from terminusgps.wialon.items.base import WialonObject
11
+ from terminusgps.wialon.session import WialonSession
12
+
13
+ WIALON_ITEM_MAP = {
14
+ "account": WialonAccount,
15
+ "avl_hw": None,
16
+ "avl_resource": WialonResource,
17
+ "avl_retranslator": WialonRetranslator,
18
+ "avl_route": WialonRoute,
19
+ "avl_unit": WialonUnit,
20
+ "avl_unit_group": WialonUnitGroup,
21
+ "user": WialonUser,
22
+ }
23
+
24
+
25
+ class WialonObjectCreationError(Exception):
26
+ """Raised when a factory fails to create a Wialon object."""
27
+
28
+
29
+ def create_wialon_object(
30
+ session: WialonSession, items_type: str, *args, **kwargs
31
+ ) -> WialonObject:
32
+ """
33
+ Creates an ``items_type`` object in Wialon and returns it as a Python object.
34
+
35
+ :param session: A valid Wialon API session.
36
+ :type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
37
+ :param items_type: A Wialon items type string.
38
+ :type items_type: :py:obj:`str`
39
+ :param args: Positional arguments to pass to the Wialon object's :py:meth:`create` method.
40
+ :param kwargs: Keyword arguments to pass to the Wialon object's :py:meth:`create` method.
41
+ :raises WialonAPIError: If something went wrong calling the Wialon API.
42
+ :raises WialonObjectCreationError: If something went wrong creating the object in Wialon.
43
+ :returns: A Wialon object.
44
+ :rtype: :py:obj:`~terminusgps.wialon.items.base.WialonObject`
45
+
46
+ """
47
+ if items_type not in WIALON_ITEM_MAP:
48
+ raise ValueError(f"Unknown Wialon items type: '{items_type}'.")
49
+
50
+ cls = WIALON_ITEM_MAP.get(items_type)
51
+ if cls is None:
52
+ raise ValueError(f"Wialon items type '{items_type}' is not implemented.")
53
+
54
+ obj = cls(session)
55
+ obj.create(*args, **kwargs)
56
+ if not obj.id:
57
+ raise WialonObjectCreationError(
58
+ f"Failed to execute create({args = }, {kwargs = }) on '{obj}'."
59
+ )
60
+ return obj