浏览代码

Mise à jour sur la syntaxe de certaines fonctions

master
TheBidouilleur 2 个月前
父节点
当前提交
88c55b080e
共有 2 个文件被更改,包括 33 次插入8 次删除
  1. +4
    -8
      gotify.py
  2. +29
    -0
      run.py

+ 4
- 8
gotify.py 查看文件

@@ -12,17 +12,13 @@ def send_notif(title, message):
})



def send_notification_for_today():
weather_today = weather_today()
weather_today = Translation[weather_today]
send_notif("Meteo d'aujourd'hui", "Le temps sera %s, Il y aura une température moyenne de %s °C" % (weather_today, get_temp_today()) )

weather = str(Translation[weather_today()])
send_notif("Meteo d'aujourd'hui", "Le temps sera %s, Il y aura une température moyenne de %s °C" % (weather, get_temp_today()) )

def send_notification_for_tomorrow():
weather_tomorrow = weather_tomorrow()
weather_tomorrow = Translation[weather_tomorrow]
send_notif("Meteo de demain", "Le temps sera %s, Il y aura une température moyenne de %s °C" % (weather_tomorrow, get_temp_tomorrow()) )
weather = str(Translation[ weather_tomorrow()])
send_notif("Meteo de demain", "Le temps sera %s, Il y aura une température moyenne de %s °C" % (weather, get_temp_tomorrow()) )


if __name__ == '__main__':


+ 29
- 0
run.py 查看文件

@@ -0,0 +1,29 @@
from gotify import send_notification_for_tomorrow, send_notification_for_today, send_notif
import datetime
import time



def main():
while True :
now = datetime.datetime.now()
print(type(now.hour))

while now.hour % 9 != 0 :
print(f"Il est {now.hour}H")
now = datetime.datetime.now()
time.sleep(600)

if now.hour == 9 :
send_notification_for_today()
elif now.hour == 18 :
send_notification_for_tomorrow()
time.sleep(3600)


if __name__ == '__main__':
try :
main()
except :
send_notif("Erreur", "Une erreur s'est produite durant l'execution du script")
main()

正在加载...
取消
保存