diff --git a/__pycache__/env.cpython-39.pyc b/__pycache__/env.cpython-39.pyc
new file mode 100644
index 0000000..fdc9594
Binary files /dev/null and b/__pycache__/env.cpython-39.pyc differ
diff --git a/env.py b/env.py
index 133410a..03fecaa 100644
--- a/env.py
+++ b/env.py
@@ -1,5 +1,5 @@
-serveurSmtp = ""
+serveurSmtp = "mail.gandi.net"
serveurPort = 465
-serveurAdrresseMail= ""
-serveurMailPassword = ""
-mailReception= ""
+serveurAdrresseMail= "contact@gregandev.fr"
+serveurMailPassword = "JuliettePuce21%"
+mailReception= "greg.lebreton@hotmail.com"
diff --git a/python-alert.py b/python-alert.py
index 739ea79..4f2b05c 100755
--- a/python-alert.py
+++ b/python-alert.py
@@ -7,8 +7,11 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
+is_in_alert = False
+time_limit = 100 # POUR LE TEMPS ENTRE CHAQUES MAILS UNE FOIS L'ALERTE DÉCLENCHÉE UNE PREMIÈRE FOIS
+
# FONCTION IMPORT URL FROM CSV + TEST REQUEST
-def import_url():
+def test_url():
print(time.ctime())
urls_hs = []
@@ -25,13 +28,11 @@ def import_url():
else:
print(url + ' / ' + str(response.status_code))
except Exception as e:
+ urls_hs.append(url)
print(str(e))
- #except:
- #print('l\'url: ' + url + ' est invalide')
return urls_hs
-
# FONCTION SEND MAIL
def send_mail(urls_hs):
@@ -46,7 +47,7 @@ def send_mail(urls_hs):
if urls_hs:
for url in urls_hs:
mail = " ".join(urls_hs)
- contenu = '
Bonjour, voici la liste des sites HS: {mail}
\n'.format(mail=mail)
+ contenu = 'Bonjour, voici la liste du ou des sites HS: {mail}
\n'.format(mail=mail)
body = MIMEText(contenu, 'html')
message.attach(body)
@@ -62,16 +63,48 @@ def send_mail(urls_hs):
mailReception,
mail_str)
server.quit()
+
+ # ALERTE = TRUE
+ is_in_alert = True
+ time_stamp = time.ctime()
+
else:
print('Tout est OK ;)')
+ is_in_alert = False
+ print(is_in_alert)
+
+# CHECK TIMER FONCTIONS
+def check_timer(time_stamp, current_time):
+ if current_time - time_stamp > time_limit:
+ print(current_time - time_stamp)
+ resend = True
+ else:
+ resend = False
+ print(current_time - time_stamp)
+
+ return resend
+
+# FONCTION CHECK IF MAIL ALREADY SEND
+def check_alert():
+ if is_in_alert:
+
+ # CHECK si timer > 1 heure
+ resend = check_timer(time_stamp, time.ctime())
+ if resend:
+ urls = test_url()
+ send_mail(urls)
+
+ else:
+ urls = test_url()
+ send_mail(urls)
# MAIN (A)
-urls = import_url()
-send_mail(urls)
+check_alert()
+
# PYTHON TIME (B)
# while True:
-# urls = import_url()
+# urls = test_url()
# send_mail(urls)
# time.sleep(300)
diff --git a/url.csv b/url.csv
index 7fe2c96..d918142 100644
--- a/url.csv
+++ b/url.csv
@@ -1,9 +1,2 @@
-https://www.gregandev.fr
-https://www.wordpress.gregandev.fr
-https://medias.gregandev.fr
-https://grego.gregandev.fr
-https://retroarch.gregandev.fr
-https://hugo.gregandev.fr
-https://gregstation.gregandev.fr
-https://psychologue-ecouen.fr
-https://www.terminal-cv.gregandev.fr
\ No newline at end of file
+https://www.google.com
+https://bidon.tld