python-terminusgps 36.6.0__py3-none-any.whl → 36.7.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.
- {python_terminusgps-36.6.0.dist-info → python_terminusgps-36.7.0.dist-info}/METADATA +1 -1
- {python_terminusgps-36.6.0.dist-info → python_terminusgps-36.7.0.dist-info}/RECORD +12 -12
- terminusgps/wialon/items/base.py +116 -111
- terminusgps/wialon/items/resource.py +117 -94
- terminusgps/wialon/items/retranslator.py +3 -1
- terminusgps/wialon/items/route.py +2 -0
- terminusgps/wialon/items/unit.py +126 -113
- terminusgps/wialon/items/unit_group.py +22 -17
- terminusgps/wialon/items/user.py +37 -120
- terminusgps/wialon/session.py +7 -8
- {python_terminusgps-36.6.0.dist-info → python_terminusgps-36.7.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-36.6.0.dist-info → python_terminusgps-36.7.0.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 36.
|
|
3
|
+
Version: 36.7.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
|
|
@@ -37,22 +37,22 @@ terminusgps/twilio/caller.py,sha256=RQax2iZ6SYHiuCvBxXkrooRWQ9J8DwKGAjxa8RYjrLI,
|
|
|
37
37
|
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
38
|
terminusgps/wialon/constants.py,sha256=05pLc_0S-x0tT87cQcxOmr8plesjOQxoXfUdjIHwI90,7732
|
|
39
39
|
terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
|
|
40
|
-
terminusgps/wialon/session.py,sha256=
|
|
40
|
+
terminusgps/wialon/session.py,sha256=iCVCnd_mTEmekKpE4vx5iWc_Pgi1i09qN8BOKoneK-g,10532
|
|
41
41
|
terminusgps/wialon/utils.py,sha256=iGOY8v7cNaSoA9Mo17d1bKAQMBtcotGq3FEQrghgvCo,11222
|
|
42
42
|
terminusgps/wialon/validators.py,sha256=j5vrtcfClAzRdRkWTvRRAmrne1t0R6cKkmYdE7fAkSs,4247
|
|
43
43
|
terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
|
|
44
|
-
terminusgps/wialon/items/base.py,sha256=
|
|
45
|
-
terminusgps/wialon/items/resource.py,sha256=
|
|
46
|
-
terminusgps/wialon/items/retranslator.py,sha256=
|
|
47
|
-
terminusgps/wialon/items/route.py,sha256=
|
|
48
|
-
terminusgps/wialon/items/unit.py,sha256=
|
|
49
|
-
terminusgps/wialon/items/unit_group.py,sha256=
|
|
50
|
-
terminusgps/wialon/items/user.py,sha256=
|
|
44
|
+
terminusgps/wialon/items/base.py,sha256=ZScO0Fi6qYd1aGvUe9kfmbZK2ezUWBI-Qqowv0foVwg,10781
|
|
45
|
+
terminusgps/wialon/items/resource.py,sha256=P3lgaE_jVvLtCHZWAbJPLCE6e8VhBwZc0okh1F460gY,18160
|
|
46
|
+
terminusgps/wialon/items/retranslator.py,sha256=2J1x7lNxRck-IEXrmJ7RM9bVL60mrZkfmczOSiUhiO8,3873
|
|
47
|
+
terminusgps/wialon/items/route.py,sha256=2dEUK9o8nwutPE03W-5GUcZrjGvbwLoExVnFV9LyedE,1326
|
|
48
|
+
terminusgps/wialon/items/unit.py,sha256=4bbaXVWPp1NaO5SJv8NHSUsItmkhXCYzVaUMhB5GRGg,11419
|
|
49
|
+
terminusgps/wialon/items/unit_group.py,sha256=HhYMZ9b7UATXeEgHkXN9r5-M_w82fabjDYADCUwBtxQ,4442
|
|
50
|
+
terminusgps/wialon/items/user.py,sha256=X5Kip414n3dIKsOJ6AieUyOC870yDWGRLIoA-TVsfPQ,5402
|
|
51
51
|
terminusgps/wialon/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
52
|
terminusgps/wialon/tests/test_items.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
53
|
terminusgps/wialon/tests/test_session.py,sha256=9mBlYchMo9NeqRIZsmxYzrM1zBHorqu4ooxqSNppLpI,1336
|
|
54
54
|
terminusgps/wialon/tests/test_utils.py,sha256=SK4PxJQGECFnzx_EQeRAQfsQ5_3FLaVcis2W9u_ibuI,1730
|
|
55
|
-
python_terminusgps-36.
|
|
56
|
-
python_terminusgps-36.
|
|
57
|
-
python_terminusgps-36.
|
|
58
|
-
python_terminusgps-36.
|
|
55
|
+
python_terminusgps-36.7.0.dist-info/METADATA,sha256=yHtIQldIVE8535R3fmf2x5uvjSL3DGix9oiqkbo_WXY,1264
|
|
56
|
+
python_terminusgps-36.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
57
|
+
python_terminusgps-36.7.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
58
|
+
python_terminusgps-36.7.0.dist-info/RECORD,,
|
terminusgps/wialon/items/base.py
CHANGED
|
@@ -6,6 +6,8 @@ from terminusgps.wialon.session import WialonSession
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class WialonBase:
|
|
9
|
+
"""Base class for Wialon objects."""
|
|
10
|
+
|
|
9
11
|
def __init__(
|
|
10
12
|
self, id: str | int | None, session: WialonSession, *args, **kwargs
|
|
11
13
|
) -> None:
|
|
@@ -18,7 +20,7 @@ class WialonBase:
|
|
|
18
20
|
:type id: :py:obj:`str` | :py:obj:`int` | :py:obj:`None`
|
|
19
21
|
:param session: A valid Wialon API session.
|
|
20
22
|
:type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
|
|
21
|
-
:raises ValueError: If ``id``
|
|
23
|
+
:raises ValueError: If ``id`` wasn't a digit.
|
|
22
24
|
:returns: Nothing.
|
|
23
25
|
:rtype: :py:obj:`None`
|
|
24
26
|
|
|
@@ -40,6 +42,11 @@ class WialonBase:
|
|
|
40
42
|
"""Returns the Wialon object type and parameters used to initialize it."""
|
|
41
43
|
return f"{type(self).__name__}(id={self.id}, session={self.session.id})"
|
|
42
44
|
|
|
45
|
+
@abstractmethod
|
|
46
|
+
def create(self, *args, **kwargs) -> int | None:
|
|
47
|
+
"""Creates a Wialon object and returns its id."""
|
|
48
|
+
raise NotImplementedError("Subclasses must implement this method.")
|
|
49
|
+
|
|
43
50
|
def populate(self) -> None:
|
|
44
51
|
"""
|
|
45
52
|
Retrieves and saves the latest data for the item from Wialon.
|
|
@@ -59,49 +66,6 @@ class WialonBase:
|
|
|
59
66
|
self._hw_type = item.get("cls")
|
|
60
67
|
self._access_lvl = item.get("uacl")
|
|
61
68
|
|
|
62
|
-
@property
|
|
63
|
-
def name(self) -> str:
|
|
64
|
-
"""Name of the Wialon object."""
|
|
65
|
-
if self._name is None:
|
|
66
|
-
self.populate()
|
|
67
|
-
return str(self._name)
|
|
68
|
-
|
|
69
|
-
@property
|
|
70
|
-
def hw_type(self) -> str:
|
|
71
|
-
"""Hardware type of the Wialon object."""
|
|
72
|
-
if self._hw_type is None:
|
|
73
|
-
self.populate()
|
|
74
|
-
return str(self._hw_type)
|
|
75
|
-
|
|
76
|
-
@property
|
|
77
|
-
def access_lvl(self) -> str:
|
|
78
|
-
"""Access level of the Wialon object."""
|
|
79
|
-
if self._access_lvl is None:
|
|
80
|
-
self.populate()
|
|
81
|
-
return str(self._access_lvl)
|
|
82
|
-
|
|
83
|
-
@property
|
|
84
|
-
def session(self) -> WialonSession:
|
|
85
|
-
"""
|
|
86
|
-
A valid Wialon API session.
|
|
87
|
-
|
|
88
|
-
:type: :py:obj:`~terminusgps.wialon.session.WialonSession`
|
|
89
|
-
|
|
90
|
-
"""
|
|
91
|
-
|
|
92
|
-
return self._session
|
|
93
|
-
|
|
94
|
-
@property
|
|
95
|
-
def id(self) -> int | None:
|
|
96
|
-
"""
|
|
97
|
-
A unique Wialon ID.
|
|
98
|
-
|
|
99
|
-
:type: :py:obj:`int` | :py:obj:`None`
|
|
100
|
-
|
|
101
|
-
"""
|
|
102
|
-
|
|
103
|
-
return int(self._id) if self._id else None
|
|
104
|
-
|
|
105
69
|
def has_access(self, other: Type["WialonBase"]) -> bool:
|
|
106
70
|
"""
|
|
107
71
|
Checks if this Wialon object has access to ``other``.
|
|
@@ -114,23 +78,19 @@ class WialonBase:
|
|
|
114
78
|
)
|
|
115
79
|
return True if self.id in response.keys() else False
|
|
116
80
|
|
|
117
|
-
@abstractmethod
|
|
118
|
-
def create(self, *args, **kwargs) -> int | None:
|
|
119
|
-
"""Creates a Wialon object and returns its id."""
|
|
120
|
-
raise NotImplementedError("Subclasses must implement this method.")
|
|
121
|
-
|
|
122
81
|
def set_measurement_unit(
|
|
123
82
|
self,
|
|
124
83
|
unit: constants.WialonMeasurementUnit = constants.WialonMeasurementUnit.US,
|
|
125
84
|
convert: bool = False,
|
|
126
85
|
) -> None:
|
|
127
86
|
"""
|
|
128
|
-
Sets the Wialon object's measurement unit
|
|
87
|
+
Sets the Wialon object's measurement unit.
|
|
129
88
|
|
|
130
|
-
:param unit: A Wialon measurement unit.
|
|
89
|
+
:param unit: A Wialon measurement unit. Default is :py:obj:`~terminusgps.wialon.constants.WialonMeasurementUnit.US`.
|
|
131
90
|
:type unit: :py:obj:`~terminusgps.constants.WialonMeasurementUnit`
|
|
132
91
|
:param convert: Whether or not to convert the object's measurements before setting the new unit.
|
|
133
92
|
:type convert: :py:obj:`bool`
|
|
93
|
+
:raises WialonError: If something went wrong with a Wialon API call.
|
|
134
94
|
:returns: Nothing.
|
|
135
95
|
:rtype: :py:obj:`None`
|
|
136
96
|
|
|
@@ -145,7 +105,7 @@ class WialonBase:
|
|
|
145
105
|
|
|
146
106
|
:param new_name: A new name.
|
|
147
107
|
:type new_name: :py:obj:`str`
|
|
148
|
-
:raises WialonError: If something
|
|
108
|
+
:raises WialonError: If something went wrong with a Wialon API call.
|
|
149
109
|
:returns: Nothing.
|
|
150
110
|
:rtype: :py:obj:`None`
|
|
151
111
|
|
|
@@ -159,59 +119,13 @@ class WialonBase:
|
|
|
159
119
|
"""
|
|
160
120
|
Deletes the Wialon object.
|
|
161
121
|
|
|
162
|
-
:raises WialonError: If something
|
|
122
|
+
:raises WialonError: If something went wrong with a Wialon API call.
|
|
163
123
|
:returns: Nothing.
|
|
164
124
|
:rtype: :py:obj:`None`
|
|
165
125
|
|
|
166
126
|
"""
|
|
167
127
|
self.session.wialon_api.item_delete_item(**{"itemId": self.id})
|
|
168
128
|
|
|
169
|
-
def _get_cfield_id(self, key: str) -> int | None:
|
|
170
|
-
"""
|
|
171
|
-
Returns a custom field id by key.
|
|
172
|
-
|
|
173
|
-
:param key: A custom field key (name).
|
|
174
|
-
:type key: :py:obj:`str`
|
|
175
|
-
:returns: The custom field's id as an integer, if found.
|
|
176
|
-
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
177
|
-
|
|
178
|
-
"""
|
|
179
|
-
cfields = (
|
|
180
|
-
self.session.wialon_api.core_search_item(
|
|
181
|
-
**{"id": str(self.id), "flags": flags.DataFlag.UNIT_CUSTOM_FIELDS}
|
|
182
|
-
)
|
|
183
|
-
.get("item", {})
|
|
184
|
-
.get("flds", {})
|
|
185
|
-
.values()
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
for field in cfields:
|
|
189
|
-
if field["n"] == key:
|
|
190
|
-
return int(field["id"])
|
|
191
|
-
|
|
192
|
-
def _get_afield_id(self, key: str) -> int | None:
|
|
193
|
-
"""
|
|
194
|
-
Returns an admin field id by key.
|
|
195
|
-
|
|
196
|
-
:param key: An admin field key (name).
|
|
197
|
-
:type key: :py:obj:`str`
|
|
198
|
-
:returns: The admin field's id as an integer, if found.
|
|
199
|
-
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
200
|
-
|
|
201
|
-
"""
|
|
202
|
-
afields = (
|
|
203
|
-
self.session.wialon_api.core_search_item(
|
|
204
|
-
**{"id": str(self.id), "flags": flags.DataFlag.UNIT_ADMIN_FIELDS}
|
|
205
|
-
)
|
|
206
|
-
.get("item", {})
|
|
207
|
-
.get("aflds", {})
|
|
208
|
-
.values()
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
for field in afields:
|
|
212
|
-
if field["n"] == key:
|
|
213
|
-
return int(field["id"])
|
|
214
|
-
|
|
215
129
|
def update_pfield(self, key: constants.WialonProfileField, value: str) -> None:
|
|
216
130
|
"""
|
|
217
131
|
Updates a profile field by key.
|
|
@@ -220,7 +134,7 @@ class WialonBase:
|
|
|
220
134
|
:type key: :py:obj:`~terminusgps.wialon.constants.WialonProfileField`
|
|
221
135
|
:param value: A string.
|
|
222
136
|
:type value: :py:obj:`str`
|
|
223
|
-
:raises WialonError: If something
|
|
137
|
+
:raises WialonError: If something went wrong with a Wialon API call.
|
|
224
138
|
:returns: Nothing.
|
|
225
139
|
:rtype: :py:obj:`None`
|
|
226
140
|
|
|
@@ -237,7 +151,7 @@ class WialonBase:
|
|
|
237
151
|
:type key: :py:obj:`str`
|
|
238
152
|
:param value: A string.
|
|
239
153
|
:type value: :py:obj:`str`
|
|
240
|
-
:raises WialonError: If something
|
|
154
|
+
:raises WialonError: If something went wrong with a Wialon API call.
|
|
241
155
|
:returns: Nothing.
|
|
242
156
|
:rtype: :py:obj:`None`
|
|
243
157
|
|
|
@@ -261,13 +175,13 @@ class WialonBase:
|
|
|
261
175
|
|
|
262
176
|
def update_cfield(self, key: str, value: str) -> None:
|
|
263
177
|
"""
|
|
264
|
-
Updates a custom field by
|
|
178
|
+
Updates a custom field by key.
|
|
265
179
|
|
|
266
180
|
:param key: A custom field key (name).
|
|
267
181
|
:type key: :py:obj:`str`
|
|
268
182
|
:param value: A string.
|
|
269
183
|
:type value: :py:obj:`str`
|
|
270
|
-
:raises WialonError: If something
|
|
184
|
+
:raises WialonError: If something went wrong with a Wialon API call.
|
|
271
185
|
:returns: Nothing.
|
|
272
186
|
:rtype: :py:obj:`None`
|
|
273
187
|
|
|
@@ -289,19 +203,96 @@ class WialonBase:
|
|
|
289
203
|
**{"itemId": self.id, "callMode": "create", "n": key, "v": value}
|
|
290
204
|
)
|
|
291
205
|
|
|
292
|
-
|
|
293
|
-
def cfields(self) -> dict[str, str]:
|
|
206
|
+
def _get_cfield_id(self, key: str) -> int | None:
|
|
294
207
|
"""
|
|
295
|
-
|
|
208
|
+
Returns a custom field id by key.
|
|
296
209
|
|
|
297
|
-
:
|
|
210
|
+
:param key: A custom field key (name).
|
|
211
|
+
:type key: :py:obj:`str`
|
|
212
|
+
:raises WialonError: If something went wrong with a Wialon API call.
|
|
213
|
+
:returns: The custom field's id as an integer, if found.
|
|
214
|
+
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
298
215
|
|
|
299
216
|
"""
|
|
300
|
-
|
|
301
|
-
|
|
217
|
+
fields = (
|
|
218
|
+
self.session.wialon_api.core_search_item(
|
|
219
|
+
**{"id": str(self.id), "flags": flags.DataFlag.UNIT_CUSTOM_FIELDS}
|
|
220
|
+
)
|
|
221
|
+
.get("item", {})
|
|
222
|
+
.get("flds", {})
|
|
223
|
+
.values()
|
|
302
224
|
)
|
|
303
|
-
|
|
304
|
-
|
|
225
|
+
|
|
226
|
+
for field in fields:
|
|
227
|
+
if field["n"] == key:
|
|
228
|
+
return int(field["id"])
|
|
229
|
+
|
|
230
|
+
def _get_afield_id(self, key: str) -> int | None:
|
|
231
|
+
"""
|
|
232
|
+
Returns an admin field id by key.
|
|
233
|
+
|
|
234
|
+
:param key: An admin field key (name).
|
|
235
|
+
:type key: :py:obj:`str`
|
|
236
|
+
:raises WialonError: If something went wrong with a Wialon API call.
|
|
237
|
+
:returns: The admin field's id as an integer, if found.
|
|
238
|
+
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
239
|
+
|
|
240
|
+
"""
|
|
241
|
+
fields = (
|
|
242
|
+
self.session.wialon_api.core_search_item(
|
|
243
|
+
**{"id": str(self.id), "flags": flags.DataFlag.UNIT_ADMIN_FIELDS}
|
|
244
|
+
)
|
|
245
|
+
.get("item", {})
|
|
246
|
+
.get("aflds", {})
|
|
247
|
+
.values()
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
for field in fields:
|
|
251
|
+
if field["n"] == key:
|
|
252
|
+
return int(field["id"])
|
|
253
|
+
|
|
254
|
+
@property
|
|
255
|
+
def name(self) -> str:
|
|
256
|
+
"""Name of the Wialon object."""
|
|
257
|
+
if self._name is None:
|
|
258
|
+
self.populate()
|
|
259
|
+
return str(self._name)
|
|
260
|
+
|
|
261
|
+
@property
|
|
262
|
+
def hw_type(self) -> str:
|
|
263
|
+
"""Hardware type of the Wialon object."""
|
|
264
|
+
if self._hw_type is None:
|
|
265
|
+
self.populate()
|
|
266
|
+
return str(self._hw_type)
|
|
267
|
+
|
|
268
|
+
@property
|
|
269
|
+
def access_lvl(self) -> str:
|
|
270
|
+
"""Access level of the Wialon object."""
|
|
271
|
+
if self._access_lvl is None:
|
|
272
|
+
self.populate()
|
|
273
|
+
return str(self._access_lvl)
|
|
274
|
+
|
|
275
|
+
@property
|
|
276
|
+
def session(self) -> WialonSession:
|
|
277
|
+
"""
|
|
278
|
+
A valid Wialon API session.
|
|
279
|
+
|
|
280
|
+
:type: :py:obj:`~terminusgps.wialon.session.WialonSession`
|
|
281
|
+
|
|
282
|
+
"""
|
|
283
|
+
|
|
284
|
+
return self._session
|
|
285
|
+
|
|
286
|
+
@property
|
|
287
|
+
def id(self) -> int | None:
|
|
288
|
+
"""
|
|
289
|
+
A Wialon object id.
|
|
290
|
+
|
|
291
|
+
:type: :py:obj:`int` | :py:obj:`None`
|
|
292
|
+
|
|
293
|
+
"""
|
|
294
|
+
|
|
295
|
+
return int(self._id) if self._id else None
|
|
305
296
|
|
|
306
297
|
@property
|
|
307
298
|
def afields(self) -> dict[str, str]:
|
|
@@ -317,6 +308,20 @@ class WialonBase:
|
|
|
317
308
|
fields = response.get("item", {}).get("aflds") if response is not None else {}
|
|
318
309
|
return {field["n"]: field["v"] for field in fields.values()} if fields else {}
|
|
319
310
|
|
|
311
|
+
@property
|
|
312
|
+
def cfields(self) -> dict[str, str]:
|
|
313
|
+
"""
|
|
314
|
+
Custom fields for the Wialon object.
|
|
315
|
+
|
|
316
|
+
:type: :py:obj:`dict`
|
|
317
|
+
|
|
318
|
+
"""
|
|
319
|
+
response = self.session.wialon_api.core_search_item(
|
|
320
|
+
**{"id": self.id, "flags": flags.DataFlag.UNIT_CUSTOM_FIELDS}
|
|
321
|
+
)
|
|
322
|
+
fields = response.get("item", {}).get("flds") if response is not None else {}
|
|
323
|
+
return {field["n"]: field["v"] for field in fields.values()} if fields else {}
|
|
324
|
+
|
|
320
325
|
@property
|
|
321
326
|
def pfields(self) -> dict[str, str]:
|
|
322
327
|
"""
|