python-terminusgps 30.0.0__py3-none-any.whl → 30.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 30.0.0
3
+ Version: 30.1.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
@@ -19,21 +19,21 @@ terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkY
19
19
  terminusgps/twilio/caller.py,sha256=TiQ4f0TDDC35he1M1iSsBM2vutdGriwtV4pc17T--6I,3552
20
20
  terminusgps/twilio/validators.py,sha256=nn7CCBTktNjcln6M4MR0ACxEsClgioSu89LRLgIiBZk,1112
21
21
  terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- terminusgps/wialon/constants.py,sha256=5Yj5YflagDaqIYrF2k8QOqyFgmNkXM05647omBTZeDc,5467
22
+ terminusgps/wialon/constants.py,sha256=-fRrvtQuSAJ6hpBJzp_Xa4GDI4LuQbqZ1z1L_QFzZiE,5609
23
23
  terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
24
24
  terminusgps/wialon/logger.py,sha256=nUBsaLMaffSaAHGHAM6mFXDzix9hbNecVtA3INVtii8,968
25
- terminusgps/wialon/session.py,sha256=UUPJFwoN4sUnB9Q7i18pjmBaKFt3wdZ1MZdj68ieO_0,9640
26
- terminusgps/wialon/utils.py,sha256=E_5OCC9wHhrKEwJv4hkTOqplJ_KmnQ5KlSPOhuXbhcg,8423
25
+ terminusgps/wialon/session.py,sha256=emB0XHJjFObtb6WbttsXZXTeRaPztcbjAV212B_Ssek,9781
26
+ terminusgps/wialon/utils.py,sha256=TKUYPs-0-nn-TeeYoARREizOZEBNvbDEzQPxt4kg_6I,9605
27
27
  terminusgps/wialon/validators.py,sha256=NNqMhoXn1M_f4Edm6oD8I7lzzXKZSqyZ6n7fR3obWj8,4241
28
28
  terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
29
- terminusgps/wialon/items/base.py,sha256=EmuTVxI7GdlCCJIwFrw0v55gDuYUWNYZ39O2Yl8K2Mc,7876
29
+ terminusgps/wialon/items/base.py,sha256=99fw7FAHszWkdEzHKbo56z3kQfJJzhPrd6tsANc4fQ8,7986
30
30
  terminusgps/wialon/items/resource.py,sha256=wfUxACO4OdzT2IdCF9oBmU_7nYiH3Xvs6BripPD5IMI,14622
31
31
  terminusgps/wialon/items/retranslator.py,sha256=sVEWrp8q1I-tO_rMTCH7TeQDDbZryIq8d9KVnhYyhH0,3795
32
32
  terminusgps/wialon/items/route.py,sha256=amNPKZqgl8pEzKA_XJudnvBPzEsfHTmrC7uF15sZVI4,1216
33
33
  terminusgps/wialon/items/unit.py,sha256=ChONjm3wlFSlbNz-yEXziNbbs4LJ70F9-MI2c-p905k,10638
34
34
  terminusgps/wialon/items/unit_group.py,sha256=QV2ZZgICaN3n6W1pFIyMLyNKB6KYBsLyKG64i-qXoOg,4113
35
35
  terminusgps/wialon/items/user.py,sha256=N30wdejdG7LXrgafdKZH74YArGkX3xpZfTucn3m3aqM,7155
36
- python_terminusgps-30.0.0.dist-info/METADATA,sha256=vXR-HgsmbNNrCtIUUUVdg-piU6D81zbNRMnL3WSg1Rg,1061
37
- python_terminusgps-30.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
- python_terminusgps-30.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
39
- python_terminusgps-30.0.0.dist-info/RECORD,,
36
+ python_terminusgps-30.1.0.dist-info/METADATA,sha256=UO4P_9gRSmHL1gV8cKAvDUt3FFEHV5fK1RMbt2JNQCU,1061
37
+ python_terminusgps-30.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ python_terminusgps-30.1.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
39
+ python_terminusgps-30.1.0.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  import enum
2
+ from typing import override
2
3
 
3
4
  from . import flags
4
5
 
@@ -108,6 +109,10 @@ class WialonItemProperty(enum.StrEnum):
108
109
  UNIQUE_ID = "sys_unique_id"
109
110
  """Object unique id."""
110
111
 
112
+ @override
113
+ def __add__(self, other: str) -> str:
114
+ return ",".join([super().__str__(), str(other)])
115
+
111
116
 
112
117
  ACCESSMASK_RESOURCE_BASIC: int = sum(
113
118
  [
@@ -21,6 +21,9 @@ class WialonBase:
21
21
  def __str__(self) -> str:
22
22
  return str(self.id)
23
23
 
24
+ def __repr__(self) -> str:
25
+ return f"{type(self).__name__}(id={self.id}, session={self.session})"
26
+
24
27
  def populate(self) -> None:
25
28
  """Retrieves and saves the latest data for the item from Wialon."""
26
29
  response = self.session.wialon_api.core_search_item(
@@ -98,6 +98,12 @@ class WialonSession:
98
98
  logging.getLogger(self.__class__.__name__), level=log_level
99
99
  ).get_logger()
100
100
 
101
+ def __str__(self) -> str:
102
+ return str(self.id)
103
+
104
+ def __repr__(self) -> str:
105
+ return f"{self.__class__}(sid={self.id})"
106
+
101
107
  def __enter__(self) -> "WialonSession":
102
108
  """Logs into the Wialon API using a token set in :py:meth:`__init__`."""
103
109
  assert self.token, "Wialon API token was not set"
@@ -6,6 +6,41 @@ from terminusgps.wialon import constants, flags
6
6
  from terminusgps.wialon.session import WialonSession
7
7
 
8
8
 
9
+ def get_carrier_names(session: WialonSession) -> list[str]:
10
+ """
11
+ Returns a list of all telecommunication carrier company names present in Wialon.
12
+
13
+ :param session: A valid Wialon API session.
14
+ :type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
15
+ :returns: A list of telecommunication carrier company names.
16
+ :rtype: :py:obj:`list`
17
+
18
+ """
19
+ afname: str = constants.WialonItemProperty.ADMIN_FIELD_NAME
20
+ afval: str = constants.WialonItemProperty.ADMIN_FIELD_VALUE
21
+ results: dict = session.wialon_api.core_search_items(
22
+ **{
23
+ "spec": {
24
+ "itemsType": constants.WialonItemsType.UNIT,
25
+ "propName": ",".join([afname, afval]),
26
+ "propValueMask": "carrier,*",
27
+ "sortType": ",".join([afname, afval]),
28
+ },
29
+ "force": 0,
30
+ "flags": flags.DataFlag.UNIT_BASE + flags.DataFlag.UNIT_ADMIN_FIELDS,
31
+ "from": 0,
32
+ "to": 0,
33
+ }
34
+ )
35
+ carrier_names: list[str] = [
36
+ field["v"]
37
+ for item in results.get("items", [{}])
38
+ for field in item.get("aflds", {}).values()
39
+ if field["n"] == "carrier" and field["v"]
40
+ ]
41
+ return sorted(list(frozenset(carrier_names)))
42
+
43
+
9
44
  def get_units_by_carrier(carrier_name: str, session: WialonSession) -> list[str]:
10
45
  """
11
46
  Returns a list of all unit ids by telecommunications carrier company name.
@@ -18,17 +53,16 @@ def get_units_by_carrier(carrier_name: str, session: WialonSession) -> list[str]
18
53
  :rtype: :py:obj:`list`
19
54
 
20
55
  """
21
- property: str = constants.WialonItemProperty.ADMIN_FIELD_NAME_VALUE.value
22
56
  results = session.wialon_api.core_search_items(
23
57
  **{
24
58
  "spec": {
25
59
  "itemsType": "avl_unit",
26
- "propName": property,
60
+ "propName": constants.WialonItemProperty.ADMIN_FIELD_NAME_VALUE,
27
61
  "propValueMask": f"carrier:{carrier_name}",
28
- "sortType": property,
62
+ "sortType": constants.WialonItemProperty.ADMIN_FIELD_NAME_VALUE,
29
63
  },
30
64
  "force": 0,
31
- "flags": flags.DataFlag.UNIT_BASE.value,
65
+ "flags": flags.DataFlag.UNIT_BASE,
32
66
  "from": 0,
33
67
  "to": 0,
34
68
  }
@@ -36,7 +70,7 @@ def get_units_by_carrier(carrier_name: str, session: WialonSession) -> list[str]
36
70
  return [item.get("id") for item in results.get("items", [])]
37
71
 
38
72
 
39
- def get_unit_by_iccid(iccid: str, session: WialonSession) -> str | None:
73
+ def get_unit_by_iccid(iccid: str, session: WialonSession) -> int | None:
40
74
  """
41
75
  Returns a unit id by iccid (SIM card #).
42
76
 
@@ -45,27 +79,24 @@ def get_unit_by_iccid(iccid: str, session: WialonSession) -> str | None:
45
79
  :param session: A valid Wialon API session.
46
80
  :type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
47
81
  :returns: The unit id, if it was found.
48
- :rtype: :py:obj:`str` | :py:obj:`None`
82
+ :rtype: :py:obj:`int` | :py:obj:`None`
49
83
 
50
84
  """
51
- property: str = constants.WialonItemProperty.ADMIN_FIELD_NAME_VALUE.value
52
85
  results = session.wialon_api.core_search_items(
53
86
  **{
54
87
  "spec": {
55
88
  "itemsType": "avl_unit",
56
- "propName": property,
89
+ "propName": constants.WialonItemProperty.ADMIN_FIELD_NAME_VALUE,
57
90
  "propValueMask": f"iccid:{iccid}",
58
- "sortType": property,
91
+ "sortType": constants.WialonItemProperty.ADMIN_FIELD_NAME_VALUE,
59
92
  },
60
93
  "force": 0,
61
- "flags": flags.DataFlag.UNIT_BASE.value,
94
+ "flags": flags.DataFlag.UNIT_BASE,
62
95
  "from": 0,
63
96
  "to": 0,
64
97
  }
65
98
  )
66
- if results.get("totalItemsCount") != 1:
67
- raise ValueError(results)
68
- return results.get("items", [{}])[0].get("id")
99
+ return int(results.get("items", [{}])[0].get("id"))
69
100
 
70
101
 
71
102
  def get_resources(session: WialonSession) -> list[int] | None: