ecodev-core 0.0.26__py3-none-any.whl → 0.0.27__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 ecodev-core might be problematic. Click here for more details.
- ecodev_core/__init__.py +2 -1
- ecodev_core/auth_configuration.py +3 -3
- ecodev_core/db_connection.py +5 -5
- ecodev_core/email_sender.py +54 -0
- {ecodev_core-0.0.26.dist-info → ecodev_core-0.0.27.dist-info}/METADATA +1 -1
- {ecodev_core-0.0.26.dist-info → ecodev_core-0.0.27.dist-info}/RECORD +8 -7
- {ecodev_core-0.0.26.dist-info → ecodev_core-0.0.27.dist-info}/LICENSE.md +0 -0
- {ecodev_core-0.0.26.dist-info → ecodev_core-0.0.27.dist-info}/WHEEL +0 -0
ecodev_core/__init__.py
CHANGED
|
@@ -40,6 +40,7 @@ from ecodev_core.db_insertion import get_raw_df
|
|
|
40
40
|
from ecodev_core.db_retrieval import count_rows
|
|
41
41
|
from ecodev_core.db_retrieval import get_rows
|
|
42
42
|
from ecodev_core.db_retrieval import ServerSideField
|
|
43
|
+
from ecodev_core.email_sender import send_email
|
|
43
44
|
from ecodev_core.enum_utils import enum_converter
|
|
44
45
|
from ecodev_core.list_utils import first_or_default
|
|
45
46
|
from ecodev_core.list_utils import first_transformed_or_default
|
|
@@ -84,4 +85,4 @@ __all__ = [
|
|
|
84
85
|
'generic_insertion', 'custom_equal', 'is_authorized_user', 'get_method', 'AppActivity',
|
|
85
86
|
'fastapi_monitor', 'dash_monitor', 'is_monitoring_user', 'get_recent_activities', 'select_user',
|
|
86
87
|
'get_access_token', 'safe_get_user', 'backup', 'group_by', 'get_excelfile', 'upsert_new_user',
|
|
87
|
-
'datify', 'safe_drop_columns', 'get_value', 'is_null']
|
|
88
|
+
'datify', 'safe_drop_columns', 'get_value', 'is_null', 'send_email']
|
|
@@ -9,9 +9,9 @@ class AuthenticationConfiguration(BaseSettings):
|
|
|
9
9
|
"""
|
|
10
10
|
Simple authentication configuration class
|
|
11
11
|
"""
|
|
12
|
-
secret_key: str
|
|
13
|
-
algorithm: str
|
|
14
|
-
access_token_expire_minutes: int
|
|
12
|
+
secret_key: str = ''
|
|
13
|
+
algorithm: str = ''
|
|
14
|
+
access_token_expire_minutes: int = 0
|
|
15
15
|
model_config = SettingsConfigDict(env_file='.env')
|
|
16
16
|
|
|
17
17
|
|
ecodev_core/db_connection.py
CHANGED
|
@@ -20,11 +20,11 @@ class DbSettings(BaseSettings):
|
|
|
20
20
|
"""
|
|
21
21
|
Settings class used to connect to the postgresql database
|
|
22
22
|
"""
|
|
23
|
-
db_host: str
|
|
24
|
-
db_port: str
|
|
25
|
-
db_name: str
|
|
26
|
-
db_username: str
|
|
27
|
-
db_password: str
|
|
23
|
+
db_host: str = ''
|
|
24
|
+
db_port: str = ''
|
|
25
|
+
db_name: str = ''
|
|
26
|
+
db_username: str = ''
|
|
27
|
+
db_password: str = ''
|
|
28
28
|
model_config = SettingsConfigDict(env_file='.env')
|
|
29
29
|
|
|
30
30
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module implementing generic email send
|
|
3
|
+
"""
|
|
4
|
+
from email.mime.image import MIMEImage
|
|
5
|
+
from email.mime.multipart import MIMEMultipart
|
|
6
|
+
from email.mime.text import MIMEText
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from smtplib import SMTP
|
|
9
|
+
from ssl import create_default_context
|
|
10
|
+
from typing import Dict
|
|
11
|
+
|
|
12
|
+
from pydantic_settings import BaseSettings
|
|
13
|
+
from pydantic_settings import SettingsConfigDict
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class EmailAuth(BaseSettings):
|
|
17
|
+
"""
|
|
18
|
+
Simple authentication configuration class
|
|
19
|
+
"""
|
|
20
|
+
email_smtp: str = ''
|
|
21
|
+
email_sender: str = ''
|
|
22
|
+
email_password: str = ''
|
|
23
|
+
model_config = SettingsConfigDict(env_file='.env')
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
EMAIL_AUTH = EmailAuth()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def send_email(email: str, body: str, topic: str, images: Dict[str, Path]) -> None:
|
|
30
|
+
"""
|
|
31
|
+
Generic email sender.
|
|
32
|
+
|
|
33
|
+
Attributes are:
|
|
34
|
+
- email: The email to which to send
|
|
35
|
+
- body: the email body
|
|
36
|
+
- topic: the email topic
|
|
37
|
+
- images: if any, the Dict of image tags:image paths to incorporate in the email
|
|
38
|
+
"""
|
|
39
|
+
em = MIMEMultipart('related')
|
|
40
|
+
em['From'] = EMAIL_AUTH.email_sender
|
|
41
|
+
em['To'] = email
|
|
42
|
+
em['Subject'] = topic
|
|
43
|
+
em.attach(MIMEText(body, 'html'))
|
|
44
|
+
for tag, img_path in images.items():
|
|
45
|
+
with open(img_path, 'rb') as fp:
|
|
46
|
+
img = MIMEImage(fp.read())
|
|
47
|
+
img.add_header('Content-ID', f'<{tag}>')
|
|
48
|
+
em.attach(img)
|
|
49
|
+
|
|
50
|
+
with SMTP(EMAIL_AUTH.email_smtp, 587) as server:
|
|
51
|
+
server.ehlo()
|
|
52
|
+
server.starttls(context=create_default_context())
|
|
53
|
+
server.login(EMAIL_AUTH.email_sender, EMAIL_AUTH.email_password)
|
|
54
|
+
server.sendmail(EMAIL_AUTH.email_sender, email, em.as_string())
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
ecodev_core/__init__.py,sha256=
|
|
1
|
+
ecodev_core/__init__.py,sha256=UfdudadIclGQH_twdS5-spE-1g7SNDAo1XFDzjE24NU,4752
|
|
2
2
|
ecodev_core/app_activity.py,sha256=_rU5uPfttHxXX5IaCuTA7K9We5w2qluJ3Xpf6i12HhY,3763
|
|
3
3
|
ecodev_core/app_rights.py,sha256=RZPdDtydFqc_nFj96huKAc56BS0qS6ScKv4Kghqd6lc,726
|
|
4
4
|
ecodev_core/app_user.py,sha256=r1bqA4H08x53XmxmjwyGKl_PFjYQazzBbVErdkztqeE,2947
|
|
5
|
-
ecodev_core/auth_configuration.py,sha256=
|
|
5
|
+
ecodev_core/auth_configuration.py,sha256=R8XH674J1HQSxMr-abvrG0zRqANRf07eMLiG4yB04gM,447
|
|
6
6
|
ecodev_core/authentication.py,sha256=aLMk2_fn1Fodrby2ywZraB3JTSsSrPsBiQq0ag0ySiY,10023
|
|
7
7
|
ecodev_core/backup.py,sha256=8fwBHic6hE8swNESIayZqqWZFHFz5f-puBWSt5f_ZLw,3119
|
|
8
8
|
ecodev_core/check_dependencies.py,sha256=aFn8GI4eBbuJT8RxsfhSSnlpNYYj_LPOH-tZF0EqfKQ,6917
|
|
9
9
|
ecodev_core/custom_equal.py,sha256=2gRn0qpyJ8-Kw9GQSueu0nLngLrRrwyMPlP6zqPac0U,899
|
|
10
|
-
ecodev_core/db_connection.py,sha256=
|
|
10
|
+
ecodev_core/db_connection.py,sha256=qRcs0MjLFfhO7pnSof1l1m1BbPqYfEsUlMQkKT9fn_4,1798
|
|
11
11
|
ecodev_core/db_filters.py,sha256=T_5JVF27UEu7sC6NOm7-W3_Y0GLfbWQO_EeTXcD2cv8,5041
|
|
12
12
|
ecodev_core/db_insertion.py,sha256=RSCyAlUObbBlWJuMRX-YFY4VgtWqYLdwRqMWw--x95Y,3646
|
|
13
13
|
ecodev_core/db_retrieval.py,sha256=IxyF3ZtKgACLiNFggK7boKggvMRKYDRD2IimxU4dap4,7345
|
|
14
|
+
ecodev_core/email_sender.py,sha256=eoRhaltPnuogNt89G8I2GKEvFk0CNIDQPoDeWZ4Uo9Y,1612
|
|
14
15
|
ecodev_core/enum_utils.py,sha256=BkQ4YQ97tXBYmMcQiSIi0mbioD5CgVU79myg1BBAXuA,556
|
|
15
16
|
ecodev_core/list_utils.py,sha256=Vyws12Jv0CLdQiQl1ym0z7E6-LJTLholYHZySQxYwhM,3006
|
|
16
17
|
ecodev_core/logger.py,sha256=AWGGNZz12Ql0JDq1wCJQxwxK2syiczEBftmuJkjbAPw,3149
|
|
@@ -19,7 +20,7 @@ ecodev_core/permissions.py,sha256=WAx-ilMu8LlQp2sjJVdkhNQieytEaEm8577ZF1HWeTY,50
|
|
|
19
20
|
ecodev_core/pydantic_utils.py,sha256=e3GH50JmcpTmd2UgrB94QSwWOlOCW3WIlVdyX9C4T-U,741
|
|
20
21
|
ecodev_core/read_write.py,sha256=auJ5bBJTVGkLRkiP_vZxVCX64B0Y-9qpsaDhovHmbas,996
|
|
21
22
|
ecodev_core/safe_utils.py,sha256=JCfxo6fcznjsL-XHNJ1TKo1UvfJB83WT5jpTFmtJwsE,6160
|
|
22
|
-
ecodev_core-0.0.
|
|
23
|
-
ecodev_core-0.0.
|
|
24
|
-
ecodev_core-0.0.
|
|
25
|
-
ecodev_core-0.0.
|
|
23
|
+
ecodev_core-0.0.27.dist-info/LICENSE.md,sha256=jebQDe1ib9LAODuNvcSoo2CoqS6P0_q8--mMTICh_kI,1074
|
|
24
|
+
ecodev_core-0.0.27.dist-info/METADATA,sha256=q3nWLxBLM5c9Iagi5n07Z-bYd1vNsig9T8rKLmNOfL4,3276
|
|
25
|
+
ecodev_core-0.0.27.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
26
|
+
ecodev_core-0.0.27.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|