python-terminusgps 1.5.8__tar.gz → 1.5.10__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.
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/PKG-INFO +1 -1
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/pyproject.toml +1 -1
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/utils.py +27 -4
- python_terminusgps-1.5.8/terminusgps/openstreetmap/polyline.py +0 -7
- python_terminusgps-1.5.8/terminusgps/openstreetmap/renderer.py +0 -3
- python_terminusgps-1.5.8/terminusgps/openstreetmap/session.py +0 -54
- python_terminusgps-1.5.8/terminusgps/wialon/__init__.py +0 -0
- python_terminusgps-1.5.8/terminusgps/wialon/maps/__init__.py +0 -0
- python_terminusgps-1.5.8/terminusgps/wialon/maps/layers.py +0 -49
- python_terminusgps-1.5.8/terminusgps/wialon/maps/renderer.py +0 -110
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/.gitignore +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/COPYING +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/README.md +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/requirements.txt +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/__init__.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/authorizenet/__init__.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/authorizenet/auth.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/aws/__init__.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/aws/secrets.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/settings.py +0 -0
- {python_terminusgps-1.5.8/terminusgps/openstreetmap → python_terminusgps-1.5.10/terminusgps/wialon}/__init__.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/constants.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/errors.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/flags.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/__init__.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/base.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/resource.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/retranslator.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/route.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/unit.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/unit_group.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/user.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/session.py +0 -0
- {python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.10
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "python-terminusgps"
|
|
3
|
-
version = "1.5.
|
|
3
|
+
version = "1.5.10"
|
|
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" } ]
|
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
import secrets
|
|
2
2
|
import string
|
|
3
3
|
|
|
4
|
+
from typing import Any
|
|
4
5
|
from .session import WialonSession
|
|
5
6
|
from .flags import DATAFLAG_UNIT_BASE
|
|
6
7
|
|
|
8
|
+
from terminusgps.wialon.items import (
|
|
9
|
+
WialonUser,
|
|
10
|
+
WialonUnit,
|
|
11
|
+
WialonUnitGroup,
|
|
12
|
+
WialonResource,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def get_wialon_cls(items_type: str) -> Any:
|
|
17
|
+
"""Returns a Wialon object class based on items_type."""
|
|
18
|
+
match items_type:
|
|
19
|
+
case "user":
|
|
20
|
+
wialon_cls = WialonUser
|
|
21
|
+
case "avl_unit":
|
|
22
|
+
wialon_cls = WialonUnit
|
|
23
|
+
case "avl_unit_group":
|
|
24
|
+
wialon_cls = WialonUnitGroup
|
|
25
|
+
case "avl_resource":
|
|
26
|
+
wialon_cls = WialonResource
|
|
27
|
+
case _:
|
|
28
|
+
raise ValueError(f"Invalid items_type '{items_type}'")
|
|
29
|
+
return wialon_cls
|
|
30
|
+
|
|
7
31
|
|
|
8
32
|
def is_unique(value: str, session: WialonSession, items_type: str = "avl_unit") -> bool:
|
|
9
33
|
"""Determines if the value is unique among Wialon objects of type 'items_type'."""
|
|
@@ -50,10 +74,9 @@ def get_id_from_iccid(iccid: str, session: WialonSession) -> str | None:
|
|
|
50
74
|
"to": 0,
|
|
51
75
|
}
|
|
52
76
|
)
|
|
53
|
-
|
|
54
|
-
if response.get("totalItemsCount", 0)
|
|
55
|
-
return
|
|
56
|
-
return response["items"][0].get("id")
|
|
77
|
+
|
|
78
|
+
if response.get("totalItemsCount", 0) == 1:
|
|
79
|
+
return response["items"][0].get("id")
|
|
57
80
|
|
|
58
81
|
|
|
59
82
|
def main() -> None:
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import requests
|
|
3
|
-
from urllib.parse import urlencode
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class OpenStreetMapSession:
|
|
7
|
-
def __init__(self, client_id: str, redirect_uri: str, scopes: list[str]) -> None:
|
|
8
|
-
self.client_id = client_id
|
|
9
|
-
self.redirect_uri = redirect_uri
|
|
10
|
-
self.scopes = scopes
|
|
11
|
-
self.base_token_url = "https://master.apis.dev.openstreetmap.org/oauth2/token?"
|
|
12
|
-
self.base_auth_url = (
|
|
13
|
-
"https://master.apis.dev.openstreetmap.org/oauth2/authorize?"
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
def generate_auth_url(self) -> str:
|
|
17
|
-
params = urlencode(
|
|
18
|
-
{
|
|
19
|
-
"response_type": "code",
|
|
20
|
-
"client_id": self.client_id,
|
|
21
|
-
"redirect_uri": self.redirect_uri,
|
|
22
|
-
"scope": "%20".join(self.scopes),
|
|
23
|
-
}
|
|
24
|
-
)
|
|
25
|
-
return self.base_auth_url + params
|
|
26
|
-
|
|
27
|
-
def get_token(self, auth_code: str, client_secret: str) -> str | None:
|
|
28
|
-
params = urlencode(
|
|
29
|
-
{
|
|
30
|
-
"grant_type": "authorization_code",
|
|
31
|
-
"code": auth_code,
|
|
32
|
-
"redirect_uri": self.redirect_uri,
|
|
33
|
-
"client_id": self.client_id,
|
|
34
|
-
"client_secret": client_secret,
|
|
35
|
-
}
|
|
36
|
-
)
|
|
37
|
-
response = requests.post(self.base_token_url + params).json()
|
|
38
|
-
self.scopes = [response.get("scope").split(" ")]
|
|
39
|
-
return response.get("access_token")
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def main() -> None:
|
|
43
|
-
scopes = os.getenv("OSM_SCOPES").split(" ")
|
|
44
|
-
session = OpenStreetMapSession(
|
|
45
|
-
client_id=os.getenv("OSM_CLIENT_ID"),
|
|
46
|
-
redirect_uri=os.getenv("OSM_REDIRECT_URI"),
|
|
47
|
-
scopes=scopes,
|
|
48
|
-
)
|
|
49
|
-
print(f"{session.generate_auth_url() = }")
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if __name__ == "__main__":
|
|
54
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
from terminusgps.wialon.maps.renderer import WialonMapRenderer
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class WialonMapLayerBase:
|
|
5
|
-
def __init__(self, renderer: WialonMapRenderer, name: str) -> None:
|
|
6
|
-
self.renderer = renderer
|
|
7
|
-
self.name = name
|
|
8
|
-
self.bounds = dict()
|
|
9
|
-
|
|
10
|
-
def __str__(self) -> str:
|
|
11
|
-
return self.name
|
|
12
|
-
|
|
13
|
-
def delete_layer(self) -> None:
|
|
14
|
-
self.renderer.session.wialon_api.render_remove_layer(**{"layerName": self.name})
|
|
15
|
-
|
|
16
|
-
def create_layer(self, data: list[dict], flags: int = 0x1) -> None:
|
|
17
|
-
raise NotImplementedError("Subclasses must implement this method")
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class WialonMapLayerGeofence(WialonMapLayerBase):
|
|
21
|
-
def create_layer(self, data: list[dict], flags: int = 0x1) -> None:
|
|
22
|
-
response = self.renderer.session.wialon_api.render_create_zones_layer(
|
|
23
|
-
**{"layerName": self.name, "flags": flags, "zones": data}
|
|
24
|
-
)
|
|
25
|
-
self.bounds = {
|
|
26
|
-
"min_lat": response.get("bounds")[0],
|
|
27
|
-
"min_lon": response.get("bounds")[1],
|
|
28
|
-
"max_lat": response.get("bounds")[2],
|
|
29
|
-
"max_lon": response.get("bounds")[3],
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class WialonMapLayerPoi(WialonMapLayerBase):
|
|
34
|
-
def create_layer(self, data: list[dict], flags: int = 0x1) -> None:
|
|
35
|
-
response = self.renderer.session.wialon_api.render_create_poi_layer(
|
|
36
|
-
**{"layerName": self.name, "flags": flags, "pois": data}
|
|
37
|
-
)
|
|
38
|
-
self.bounds = {
|
|
39
|
-
"min_lat": response.get("bounds")[0],
|
|
40
|
-
"min_lon": response.get("bounds")[1],
|
|
41
|
-
"max_lat": response.get("bounds")[2],
|
|
42
|
-
"max_lon": response.get("bounds")[3],
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class WialonMapLayerTrack(WialonMapLayerBase):
|
|
47
|
-
def __init__(self, **kwargs) -> None:
|
|
48
|
-
self.units = []
|
|
49
|
-
return super().__init__(**kwargs)
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
from django.conf import ImproperlyConfigured, settings
|
|
2
|
-
|
|
3
|
-
from terminusgps.wialon.session import WialonSession
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class WialonMapRenderer:
|
|
7
|
-
def __init__(
|
|
8
|
-
self, sid: str | None = None, gis_host: str = "hst-api.wialon.com"
|
|
9
|
-
) -> None:
|
|
10
|
-
if not hasattr(settings, "WIALON_TOKEN"):
|
|
11
|
-
raise ImproperlyConfigured("'WIALON_TOKEN' setting is required.")
|
|
12
|
-
|
|
13
|
-
self.host = gis_host
|
|
14
|
-
self.layers = []
|
|
15
|
-
self.session = WialonSession(sid=sid)
|
|
16
|
-
|
|
17
|
-
@property
|
|
18
|
-
def total_layers(self) -> int:
|
|
19
|
-
return len(self.layers)
|
|
20
|
-
|
|
21
|
-
def get_events(self):
|
|
22
|
-
return self.session.wialon_api.avl_evts()
|
|
23
|
-
|
|
24
|
-
def toggle_layer(self, name: str, enabled: bool = True) -> None:
|
|
25
|
-
self.session.wialon_api.render_enable_layer(
|
|
26
|
-
**{"layerName": name, "enable": enabled}
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
def delete_all_layers(self) -> None:
|
|
30
|
-
self.session.wialon_api.render_remove_all_layers({})
|
|
31
|
-
self.layers = []
|
|
32
|
-
|
|
33
|
-
def get_tiles_url(self, x: int, y: int, z: int) -> str:
|
|
34
|
-
MIN_ZOOM, MAX_ZOOM = 2, 17
|
|
35
|
-
z = min(max(z, MIN_ZOOM), MAX_ZOOM)
|
|
36
|
-
return f"http://{self.host}/avl_render/{x}_{y}_{z}/{self.session.id}.png"
|
|
37
|
-
|
|
38
|
-
def update_locale(
|
|
39
|
-
self,
|
|
40
|
-
tz: int,
|
|
41
|
-
lang: str = "en",
|
|
42
|
-
flags: int = 1,
|
|
43
|
-
date_fmt: str = "%m-%E-%Y %H:%M:%S",
|
|
44
|
-
density: int = 256 * 256,
|
|
45
|
-
) -> None:
|
|
46
|
-
"""
|
|
47
|
-
Updates the renderer locale.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Date Format:
|
|
51
|
-
|
|
52
|
-
+-----------+------------------------------------------------------------------------+
|
|
53
|
-
| Parameter | Description |
|
|
54
|
-
+===========+========================================================================+
|
|
55
|
-
| ``%H`` | The hour of the day with leading zero if required ("00" to "23") |
|
|
56
|
-
+-----------+------------------------------------------------------------------------+
|
|
57
|
-
| ``%B`` | The full month name ("January" to "December") |
|
|
58
|
-
+-----------+------------------------------------------------------------------------+
|
|
59
|
-
| ``%b`` | Abbreviated month name ("Jan" to "Dec") |
|
|
60
|
-
+-----------+------------------------------------------------------------------------+
|
|
61
|
-
| ``%m`` | The month of the year with leading zero if required ("01" to "12") |
|
|
62
|
-
+-----------+------------------------------------------------------------------------+
|
|
63
|
-
| ``%l`` | The month of the year between 1-12 ("1" to "12") |
|
|
64
|
-
+-----------+------------------------------------------------------------------------+
|
|
65
|
-
| ``%P`` | Format Persian calendar ("01 Farvardin 1392 00:00:00") |
|
|
66
|
-
+-----------+------------------------------------------------------------------------+
|
|
67
|
-
| ``%A`` | The full day name ("Monday" to "Sunday") |
|
|
68
|
-
+-----------+------------------------------------------------------------------------+
|
|
69
|
-
| ``%a`` | Abbreviated day name ("Mon" to "Sun") |
|
|
70
|
-
+-----------+------------------------------------------------------------------------+
|
|
71
|
-
| ``%E`` | The day of the month with a leading zero if required ("01" to "31") |
|
|
72
|
-
+-----------+------------------------------------------------------------------------+
|
|
73
|
-
| ``%e`` | The day of the month between 1 and 31 ("1" to "31") |
|
|
74
|
-
+-----------+------------------------------------------------------------------------+
|
|
75
|
-
| ``%I`` | The hour of the day with leading zero if required ("01" to "12") |
|
|
76
|
-
+-----------+------------------------------------------------------------------------+
|
|
77
|
-
| ``%M`` | The minute of the hour with leading zero if required ("00" to "59") |
|
|
78
|
-
+-----------+------------------------------------------------------------------------+
|
|
79
|
-
| ``%S`` | The seconds of the minute with leading zero if required ("00" to "59") |
|
|
80
|
-
+-----------+------------------------------------------------------------------------+
|
|
81
|
-
| ``%p`` | Displays the A.M./P.M. designator ("AM" or "PM") |
|
|
82
|
-
+-----------+------------------------------------------------------------------------+
|
|
83
|
-
| ``%Y`` | The full four digit year ("1999" or "2000") |
|
|
84
|
-
+-----------+------------------------------------------------------------------------+
|
|
85
|
-
| ``%y`` | The year as a two digit number ("99" or "00") |
|
|
86
|
-
+-----------+------------------------------------------------------------------------+
|
|
87
|
-
|
|
88
|
-
"""
|
|
89
|
-
self.session.wialon_api.render_set_locale(
|
|
90
|
-
**{
|
|
91
|
-
"tzOffset": tz,
|
|
92
|
-
"language": lang,
|
|
93
|
-
"flags": flags,
|
|
94
|
-
"formatDate": date_fmt,
|
|
95
|
-
"density": density,
|
|
96
|
-
}
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def main() -> None:
|
|
101
|
-
from terminusgps.wialon.maps.layers import WialonMapLayerPoi
|
|
102
|
-
|
|
103
|
-
with WialonSession() as session:
|
|
104
|
-
renderer = WialonMapRenderer(session.id)
|
|
105
|
-
layer = WialonMapLayerPoi(renderer, "terminusgps_office")
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if __name__ == "__main__":
|
|
110
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/retranslator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_terminusgps-1.5.8 → python_terminusgps-1.5.10}/terminusgps/wialon/items/unit_group.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|