From 27485e8e7ecc62908ca44fe843713ca0863e7c3c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 30 May 2021 17:23:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20datetime=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nest_crawler/alert_trigger.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nest_crawler/alert_trigger.py b/nest_crawler/alert_trigger.py index d65ed25..c33b240 100644 --- a/nest_crawler/alert_trigger.py +++ b/nest_crawler/alert_trigger.py @@ -4,7 +4,6 @@ from .authentication import authenticate import smtplib import os import tweepy as tw -import datetime MESSAGE = "❗ {alert_name}: la soglia di allerta è stata superata alle {now}!" @@ -55,7 +54,7 @@ def send_notification_email(alert): smtpObj.login(os.environ["SMTP_USERNAME"], os.environ["SMTP_PASSWORD"]) smtpObj.sendmail(os.environ["SMTP_FROM_EMAIL"], alert.repository.owner.email, - MESSAGE.format(alert_name=alert.name, now=datetime.datetime.now().isoformat())) + MESSAGE.format(alert_name=alert.name, now=datetime.now().isoformat())) print("Successfully sent email") except smtplib.SMTPException: print("Error: unable to send email") @@ -69,7 +68,7 @@ def send_notification_tweet(alert): conditions_string = conditions_string[:-1] print(conditions_string) try: - api.update_status(MESSAGE.format(alert_name=alert.name, now=datetime.datetime.now().isoformat())) + api.update_status(MESSAGE.format(alert_name=alert.name, now=datetime.now().isoformat())) except tw.errors.Forbidden: print("Il tweet e' gia' stato pubblicato")