Bläddra i källkod

Ajout de Gotify pour les notifications

master
TheBidouilleur 2 månader sedan
förälder
incheckning
30ec4322eb
1 ändrade filer med 13 tillägg och 9 borttagningar
  1. +13
    -9
      run.py

+ 13
- 9
run.py Visa fil

@@ -1,10 +1,11 @@


from datetime import datetime from datetime import datetime
import psutil
import time
import psutil, time, requests
from win10toast import ToastNotifier from win10toast import ToastNotifier
toaster = ToastNotifier() toaster = ToastNotifier()
from datetime import datetime from datetime import datetime
from config import Gotify


datetime.today().strftime('%Y-%m-%d') datetime.today().strftime('%Y-%m-%d')


@@ -47,7 +48,7 @@ def countdown(founded_process):
secondes = '0' + str(secondes) secondes = '0' + str(secondes)




send_gotify('NSL ' + searching_process, "Uptime du processus : %s:%s:%s " % (heures, minutes, secondes) )
print("Uptime du processus : %s:%s:%s " % (heures, minutes, secondes)) print("Uptime du processus : %s:%s:%s " % (heures, minutes, secondes))
toaster.show_toast("NoSocialLife Counter","Arret du programme : " + searching_process ) toaster.show_toast("NoSocialLife Counter","Arret du programme : " + searching_process )
toaster.show_toast("NoSocialLife Counter","Uptime du processus : %s:%s:%s " % (heures, minutes, secondes)) toaster.show_toast("NoSocialLife Counter","Uptime du processus : %s:%s:%s " % (heures, minutes, secondes))
@@ -57,6 +58,7 @@ def countdown(founded_process):
f.write(date + " | Programme : " + searching_process + " | Uptime du processus : %s:%s:%s " % (heures, minutes, secondes)) f.write(date + " | Programme : " + searching_process + " | Uptime du processus : %s:%s:%s " % (heures, minutes, secondes))
f.close() f.close()



def main(): def main():
toaster.show_toast("NoSocialLife Counter","Programme recherché : " + searching_process ) toaster.show_toast("NoSocialLife Counter","Programme recherché : " + searching_process )
process_running = False process_running = False
@@ -77,7 +79,12 @@ def main():
countdown(founded_process) countdown(founded_process)





def send_gotify(title, message):
resp = requests.post(Gotify['URL'] + '?token=' + Gotify['token_gotify'] , json={
"message": message,
"priority": 2,
"title": title
})


def catch_process(searching_process): def catch_process(searching_process):
catched = False catched = False
@@ -92,8 +99,5 @@ def catch_process(searching_process):




if __name__ == '__main__': if __name__ == '__main__':
try :
main()
except :
print("Erreur, Redemarrage du script")
main()

main()

Laddar…
Avbryt
Spara