arpakitlib 1.8.143__py3-none-any.whl → 1.8.149__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.
@@ -0,0 +1,90 @@
1
+ import asyncio
2
+ import datetime as dt
3
+ import logging
4
+ import smtplib
5
+ from email.message import EmailMessage
6
+
7
+ import aiosmtplib
8
+
9
+ from project.core.settings import get_cached_settings
10
+ from project.core.util import setup_logging
11
+
12
+ _logger = logging.getLogger(__name__)
13
+
14
+
15
+ def sync_send_email(
16
+ *,
17
+ to_email: str,
18
+ subject: str = "Gamer.Market",
19
+ html_content: str,
20
+ emulate: bool = False
21
+ ):
22
+ to_email = to_email.strip()
23
+
24
+ if emulate:
25
+ _logger.info(f"emulate email sending, {to_email=}, {subject=}, {html_content=}")
26
+ return
27
+
28
+ message = EmailMessage()
29
+ message["From"] = get_cached_settings().email_smtp_user
30
+ message["To"] = to_email
31
+ message["Subject"] = subject
32
+ message.add_alternative(html_content, subtype="html")
33
+
34
+ with smtplib.SMTP_SSL(
35
+ host=get_cached_settings().email_smtp_hostname,
36
+ port=get_cached_settings().email_smtp_port,
37
+ timeout=dt.timedelta(seconds=15).total_seconds()
38
+
39
+ ) as server:
40
+ server.login(
41
+ get_cached_settings().email_smtp_user,
42
+ get_cached_settings().email_smtp_password
43
+ )
44
+ server.send_message(message)
45
+
46
+ _logger.info(f"email was send, {to_email=}")
47
+
48
+
49
+ async def async_send_email(
50
+ *,
51
+ to_email: str,
52
+ subject: str = "Gamer.Market",
53
+ html_content: str,
54
+ emulate: bool = False
55
+ ):
56
+ to_email = to_email.strip()
57
+
58
+ if emulate:
59
+ _logger.info(f"emulate email sending, {to_email=}, {subject=}, {html_content=}")
60
+ return
61
+
62
+ message = EmailMessage()
63
+ message["From"] = get_cached_settings().email_smtp_user
64
+ message["To"] = to_email
65
+ message["Subject"] = subject
66
+ message.add_alternative(html_content, subtype="html")
67
+
68
+ await aiosmtplib.send(
69
+ message,
70
+ hostname=get_cached_settings().email_smtp_hostname,
71
+ port=get_cached_settings().email_smtp_port,
72
+ username=get_cached_settings().email_smtp_user,
73
+ password=get_cached_settings().email_smtp_password,
74
+ use_tls=True,
75
+ timeout=dt.timedelta(seconds=15).total_seconds()
76
+ )
77
+
78
+ _logger.info(f"email was send, {to_email=}")
79
+
80
+
81
+ async def __async_example():
82
+ setup_logging()
83
+ await async_send_email(
84
+ to_email="arpakit@gmail.com",
85
+ html_content="Hello world 2"
86
+ )
87
+
88
+
89
+ if __name__ == '__main__':
90
+ asyncio.run(__async_example())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: arpakitlib
3
- Version: 1.8.143
3
+ Version: 1.8.149
4
4
  Summary: arpakitlib
5
5
  License: Apache-2.0
6
6
  Keywords: arpakitlib,arpakit,arpakit-company,arpakitcompany,arpakit_company
@@ -51,6 +51,7 @@ Requires-Dist: pymongo (>=4.10.1,<5.0.0)
51
51
  Requires-Dist: pytelegrambotapi (>=4.27.0,<5.0.0)
52
52
  Requires-Dist: pytz (>=2024.2,<2025.0)
53
53
  Requires-Dist: pyzabbix (>=1.3.1,<2.0.0)
54
+ Requires-Dist: requests-ntlm (>=1.3.0,<2.0.0)
54
55
  Requires-Dist: requests[socks] (>=2.32.3,<3.0.0)
55
56
  Requires-Dist: scipy (>=1.15.1,<2.0.0)
56
57
  Requires-Dist: speechrecognition (>=3.14.3,<4.0.0)
@@ -357,6 +357,7 @@ arpakitlib/_arpakit_project_template_v_5/project/tg_bot_notifier/tg_bot_notifier
357
357
  arpakitlib/_arpakit_project_template_v_5/project/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
358
358
  arpakitlib/_arpakit_project_template_v_5/project/util/arpakitlib_project_template_util.py,sha256=syA_IuszHVub0zm0sVdB4_7rPJXwXRW4JmQ4qHbjXPk,396
359
359
  arpakitlib/_arpakit_project_template_v_5/project/util/etc.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
360
+ arpakitlib/_arpakit_project_template_v_5/project/util/send_email_.py,sha256=ehpBiIt6vpUXeuIY_tvr-80LGM7VBCUhgASGZpWy-Ok,2387
360
361
  arpakitlib/_arpakit_project_template_v_5/todo.txt,sha256=q132Jbx229ThY77S3YiN-Cj5AVm7k1VlJcMYIbZUHUY,3
361
362
  arpakitlib/ar_additional_model_util.py,sha256=GFg-glLCxH9X95R2bhTJsscVwv37FgE1qbaAAyXrnIE,917
362
363
  arpakitlib/ar_aiogram_util.py,sha256=4bizX5Xg-E2-r2TXXGQGanJozsIWPVf5luO3vKUN8p8,8471
@@ -405,8 +406,8 @@ arpakitlib/ar_ssh_runner_util.py,sha256=yvAwza480MkHKvLkDEsR7JNh2bYNs6P9rCVo4NA8
405
406
  arpakitlib/ar_str_util.py,sha256=2lGpnXDf2h1cBZpVf5i1tX_HCv5iBd6IGnrCw4QWWlY,4350
406
407
  arpakitlib/ar_type_util.py,sha256=Cs_tef-Fc5xeyAF54KgISCsP11NHyzIsglm4S3Xx7iM,4049
407
408
  arpakitlib/ar_yookassa_api_client_util.py,sha256=VozuZeCJjmLd1zj2BdC9WfiAQ3XYOrIMsdpNK-AUlm0,5347
408
- arpakitlib-1.8.143.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
409
- arpakitlib-1.8.143.dist-info/METADATA,sha256=4gQpoKodyOIsSa8mC5oZIOzNhQ1enpSFYYVpX3O9p14,3660
410
- arpakitlib-1.8.143.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
411
- arpakitlib-1.8.143.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
412
- arpakitlib-1.8.143.dist-info/RECORD,,
409
+ arpakitlib-1.8.149.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
410
+ arpakitlib-1.8.149.dist-info/METADATA,sha256=6PCWAbE5oRC_-nHI_hKCKx1NDT8snzoGyx_5eoEYfhE,3706
411
+ arpakitlib-1.8.149.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
412
+ arpakitlib-1.8.149.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
413
+ arpakitlib-1.8.149.dist-info/RECORD,,