mirror of
https://github.com/Findus23/suntracking.git
synced 2024-08-27 19:52:18 +02:00
send correct text
This commit is contained in:
parent
a8588a9914
commit
07dd0dde7a
2 changed files with 18 additions and 13 deletions
25
main.py
25
main.py
|
@ -3,10 +3,14 @@ import time
|
|||
import schedule
|
||||
|
||||
import guess
|
||||
from sendmail import sendmail
|
||||
|
||||
|
||||
def send_notification(on_time=False):
|
||||
print("DAS IST EIN TEST")
|
||||
def send_notification(time, future=False):
|
||||
subject = "☀️ at {time}".format(time=time)
|
||||
if future:
|
||||
subject += " - {min} minutes left".format(min=future)
|
||||
sendmail(subject, subject)
|
||||
return schedule.CancelJob
|
||||
|
||||
|
||||
|
@ -17,16 +21,17 @@ def create_schedule():
|
|||
standard_derivation = float(lines[1].strip())
|
||||
print(altitude, standard_derivation)
|
||||
|
||||
s = schedule.every().day
|
||||
|
||||
s.at_time = guess.get_time(altitude).time()
|
||||
s.at_time = guess.get_time(altitude).time()
|
||||
s.do(send_notification, on_time=True)
|
||||
sunset_time = guess.get_time(altitude).time()
|
||||
|
||||
s = schedule.every().day
|
||||
print(guess.get_time(altitude + standard_derivation * 3).time())
|
||||
s.at_time = guess.get_time(altitude + standard_derivation * 3).time()
|
||||
s.do(send_notification)
|
||||
s.at_time = sunset_time
|
||||
s.do(send_notification, sunset_time)
|
||||
|
||||
prewarn_time = guess.get_time(altitude + standard_derivation * 3).time()
|
||||
s = schedule.every().day
|
||||
print(prewarn_time)
|
||||
s.at_time = prewarn_time
|
||||
s.do(send_notification, sunset_time, future=prewarn_time - sunset_time)
|
||||
|
||||
|
||||
create_schedule()
|
||||
|
|
|
@ -4,10 +4,10 @@ from email.mime.text import MIMEText
|
|||
from config import by, to
|
||||
|
||||
|
||||
def sendmail():
|
||||
msg = MIMEText("test")
|
||||
def sendmail(subject, text):
|
||||
msg = MIMEText(text)
|
||||
|
||||
msg['Subject'] = "subject"
|
||||
msg['Subject'] = subject
|
||||
msg['From'] = by
|
||||
msg['To'] = to
|
||||
|
||||
|
|
Loading…
Reference in a new issue