python-terminusgps 24.5.0__py3-none-any.whl → 25.0.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.
- {python_terminusgps-24.5.0.dist-info → python_terminusgps-25.0.0.dist-info}/METADATA +1 -1
- {python_terminusgps-24.5.0.dist-info → python_terminusgps-25.0.0.dist-info}/RECORD +5 -6
- terminusgps/twilio/caller.py +48 -14
- terminusgps/twilio/logger.py +0 -29
- {python_terminusgps-24.5.0.dist-info → python_terminusgps-25.0.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-24.5.0.dist-info → python_terminusgps-25.0.0.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version:
|
|
3
|
+
Version: 25.0.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
|
|
@@ -15,8 +15,7 @@ terminusgps/aws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
15
15
|
terminusgps/aws/secrets.py,sha256=MxQEmmBLpMUQ2tYAsHdCYf-7RZ84LiogdKcTsACX5dw,361
|
|
16
16
|
terminusgps/aws/ses.py,sha256=sDca2GjMaZvUt3kUPtGCpcqHiOkij9lMV1ogZofgYUU,2372
|
|
17
17
|
terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
|
|
18
|
-
terminusgps/twilio/caller.py,sha256=
|
|
19
|
-
terminusgps/twilio/logger.py,sha256=qlbOUvqBt7dNUOQGgn_N8_nwiqo0ewbqP9VN4N7dCrM,968
|
|
18
|
+
terminusgps/twilio/caller.py,sha256=TiQ4f0TDDC35he1M1iSsBM2vutdGriwtV4pc17T--6I,3552
|
|
20
19
|
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
20
|
terminusgps/wialon/constants.py,sha256=n1ux68oWYWnzeZdN811Iw_Lk78KBM0YMJMoonn67uZY,1723
|
|
22
21
|
terminusgps/wialon/flags.py,sha256=_NIL3mrEGhvI5YISVjimjYtUatdgOqhZPJX368MtKSU,13959
|
|
@@ -31,7 +30,7 @@ terminusgps/wialon/items/route.py,sha256=PTJx1gmT_PGz7nlSSUS2VzjYD-aAuvkEOIdIFne
|
|
|
31
30
|
terminusgps/wialon/items/unit.py,sha256=K0kmzFEInR3dAQVtMUA6M7KNy7HlD5IKl7f7YElr2sQ,9116
|
|
32
31
|
terminusgps/wialon/items/unit_group.py,sha256=Stp-WfCGbOqcnxV6FU1AKtV7KIxIwCHa0NwhNJfgRoM,5032
|
|
33
32
|
terminusgps/wialon/items/user.py,sha256=INwAibQVmjNNelepQXMfDevgJqMvIjHHgEjAMLRvhB0,7082
|
|
34
|
-
python_terminusgps-
|
|
35
|
-
python_terminusgps-
|
|
36
|
-
python_terminusgps-
|
|
37
|
-
python_terminusgps-
|
|
33
|
+
python_terminusgps-25.0.0.dist-info/METADATA,sha256=RRNrckAzXzk1PVqHehcdAQ9rKWU1B7bFxZmyrkVYslE,946
|
|
34
|
+
python_terminusgps-25.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
35
|
+
python_terminusgps-25.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
36
|
+
python_terminusgps-25.0.0.dist-info/RECORD,,
|
terminusgps/twilio/caller.py
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
import logging
|
|
3
2
|
from typing import Any
|
|
4
3
|
|
|
5
4
|
import twilio.rest
|
|
6
5
|
from django.conf import settings
|
|
6
|
+
from django.core.exceptions import ImproperlyConfigured
|
|
7
7
|
from twilio.http.async_http_client import AsyncTwilioHttpClient
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
if not hasattr(settings, "TWILIO_SID"):
|
|
10
|
+
raise ImproperlyConfigured("'TWILIO_SID' setting is required.")
|
|
11
|
+
if not hasattr(settings, "TWILIO_TOKEN"):
|
|
12
|
+
raise ImproperlyConfigured("'TWILIO_TOKEN' setting is required.")
|
|
13
|
+
if not hasattr(settings, "TWILIO_FROM_NUMBER"):
|
|
14
|
+
raise ImproperlyConfigured("'TWILIO_FROM_NUMBER' setting is required.")
|
|
15
|
+
if not hasattr(settings, "TWILIO_MESSAGING_SID"):
|
|
16
|
+
raise ImproperlyConfigured("'TWILIO_MESSAGING_SID' setting is required.")
|
|
10
17
|
|
|
11
18
|
|
|
12
19
|
class TwilioCaller:
|
|
13
|
-
def __init__(self
|
|
20
|
+
def __init__(self) -> None:
|
|
21
|
+
"""Sets Twilio messaging session variables."""
|
|
14
22
|
self.client_sid = settings.TWILIO_SID
|
|
15
23
|
self.client_token = settings.TWILIO_TOKEN
|
|
16
24
|
self.from_number = settings.TWILIO_FROM_NUMBER
|
|
17
25
|
self.messaging_sid = settings.TWILIO_MESSAGING_SID
|
|
18
|
-
self.logger = TwilioLogger(
|
|
19
|
-
logging.getLogger(self.__class__.__name__), level=log_level
|
|
20
|
-
).get_logger()
|
|
21
26
|
|
|
22
27
|
def __enter__(self) -> "TwilioCaller":
|
|
28
|
+
"""Creates an asyncronous Twilio client."""
|
|
23
29
|
self.client = twilio.rest.Client(
|
|
24
30
|
self.client_sid, self.client_token, http_client=AsyncTwilioHttpClient()
|
|
25
31
|
)
|
|
@@ -31,10 +37,21 @@ class TwilioCaller:
|
|
|
31
37
|
async def create_notification(
|
|
32
38
|
self, to_number: str, message: str, method: str = "sms"
|
|
33
39
|
) -> asyncio.Task[Any]:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
"""
|
|
41
|
+
Returns an awaitable notification task.
|
|
42
|
+
|
|
43
|
+
Available methods are ``"sms"``, ``"call"`` and ``"phone"``.
|
|
37
44
|
|
|
45
|
+
:param to_number: A phone number to notify.
|
|
46
|
+
:type to_number: :py:obj:`str`
|
|
47
|
+
:param message: A notification message.
|
|
48
|
+
:type message: :py:obj:`str`
|
|
49
|
+
:param method: A notification method. Default is ``"sms"``.
|
|
50
|
+
:type method: :py:obj:`str`
|
|
51
|
+
:returns: An awaitable task.
|
|
52
|
+
:rtype: :py:obj:`~asyncio.Task`
|
|
53
|
+
|
|
54
|
+
"""
|
|
38
55
|
match method:
|
|
39
56
|
case "sms":
|
|
40
57
|
return asyncio.create_task(
|
|
@@ -44,12 +61,21 @@ class TwilioCaller:
|
|
|
44
61
|
return asyncio.create_task(
|
|
45
62
|
self.create_call(to_number=to_number, message=message)
|
|
46
63
|
)
|
|
47
|
-
case "log":
|
|
48
|
-
return asyncio.create_task(self.create_log(message=message))
|
|
49
64
|
case _:
|
|
50
65
|
raise ValueError(f"Unsupported TwilioCaller method '{method}'.")
|
|
51
66
|
|
|
52
67
|
async def create_call(self, to_number: str, message: str) -> None:
|
|
68
|
+
"""
|
|
69
|
+
Calls ``to_number`` and reads ``message`` aloud.
|
|
70
|
+
|
|
71
|
+
:param to_number: A phone number.
|
|
72
|
+
:type to_number: :py:obj:`str`
|
|
73
|
+
:param message: A message to be read aloud.
|
|
74
|
+
:type message: :py:obj:`str`
|
|
75
|
+
:returns: Nothing.
|
|
76
|
+
:rtype: :py:obj:`None`
|
|
77
|
+
|
|
78
|
+
"""
|
|
53
79
|
await self.client.calls.create_async(
|
|
54
80
|
to=to_number,
|
|
55
81
|
from_=self.from_number,
|
|
@@ -57,12 +83,20 @@ class TwilioCaller:
|
|
|
57
83
|
)
|
|
58
84
|
|
|
59
85
|
async def create_sms(self, to_number: str, message: str) -> None:
|
|
86
|
+
"""
|
|
87
|
+
Texts ``message`` to ``to_number``.
|
|
88
|
+
|
|
89
|
+
:param to_number: A phone number.
|
|
90
|
+
:type to_number: :py:obj:`str`
|
|
91
|
+
:param message: A message to be texted.
|
|
92
|
+
:type message: :py:obj:`str`
|
|
93
|
+
:returns: Nothing.
|
|
94
|
+
:rtype: :py:obj:`None`
|
|
95
|
+
|
|
96
|
+
"""
|
|
60
97
|
await self.client.messages.create_async(
|
|
61
98
|
to=to_number,
|
|
62
99
|
from_=self.from_number,
|
|
63
100
|
body=message,
|
|
64
101
|
messaging_service_sid=self.messaging_sid,
|
|
65
102
|
)
|
|
66
|
-
|
|
67
|
-
async def create_log(self, message: str) -> None:
|
|
68
|
-
self.logger.info(message)
|
terminusgps/twilio/logger.py
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class TwilioLogger:
|
|
5
|
-
def __init__(
|
|
6
|
-
self,
|
|
7
|
-
logger: logging.Logger,
|
|
8
|
-
level: int = logging.DEBUG,
|
|
9
|
-
format: str = "%(name)s - %(levelname)s - %(asctime)s - %(message)s",
|
|
10
|
-
use_stream_handler: bool = True,
|
|
11
|
-
use_file_handler: bool = False,
|
|
12
|
-
filename: str = "twilio_debug.log",
|
|
13
|
-
) -> None:
|
|
14
|
-
self.logger = logger
|
|
15
|
-
self.logger.setLevel(level)
|
|
16
|
-
formatter = logging.Formatter(format)
|
|
17
|
-
|
|
18
|
-
if use_stream_handler and not self.logger.handlers:
|
|
19
|
-
stream_handler = logging.StreamHandler()
|
|
20
|
-
stream_handler.setFormatter(formatter)
|
|
21
|
-
self.logger.addHandler(stream_handler)
|
|
22
|
-
|
|
23
|
-
if use_file_handler and not self.logger.handlers:
|
|
24
|
-
file_handler = logging.FileHandler(filename)
|
|
25
|
-
file_handler.setFormatter(formatter)
|
|
26
|
-
self.logger.addHandler(file_handler)
|
|
27
|
-
|
|
28
|
-
def get_logger(self) -> logging.Logger:
|
|
29
|
-
return self.logger
|
|
File without changes
|
{python_terminusgps-24.5.0.dist-info → python_terminusgps-25.0.0.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|