-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import smtplib | ||
from email.message import EmailMessage | ||
|
||
import settings | ||
|
||
|
||
def notify(uploaded_files): | ||
buff = [] | ||
for stem, files in uploaded_files.items(): | ||
buff.append('<p>') | ||
buff.append(f'<b>{stem}</b><br>') | ||
for file, url in files: | ||
buff.append(f'<a href="{url}">{file}</a><br>') | ||
buff.append('</p>') | ||
uploaded_files = '\n'.join(buff) | ||
subject = '📊 Actualización de datos SIEMAC' | ||
content = f'''<p>Hola,</p> | ||
<p>Se ha realizado la subida de datos SIEMAC tras el scraping a EUROSTAT y su posterior | ||
procesamiento.</p> | ||
<p>Relación de ficheros con sus URLs de descarga:</p> | ||
{uploaded_files} | ||
Saludos,<br> | ||
El equipo de informática. | ||
''' | ||
|
||
msg = EmailMessage() | ||
msg.set_content(content, subtype='html') | ||
msg['Subject'] = subject | ||
msg['From'] = settings.NOTIFICATION_FROM_ADDR | ||
msg['To'] = settings.NOTIFICATION_TO_ADDRS | ||
|
||
s = smtplib.SMTP(settings.SMTP_SERVER, port=settings.SMTP_PORT) | ||
s.login(settings.SMTP_USERNAME, settings.SMTP_PASSWORD) | ||
s.send_message(msg) | ||
s.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters