| @@ -4,29 +4,79 @@ import psutil | |||
| import time | |||
| from win10toast import ToastNotifier | |||
| toaster = ToastNotifier() | |||
| from datetime import datetime | |||
| datetime.today().strftime('%Y-%m-%d') | |||
| print("Example : firefox.exe") | |||
| searching_process = input("Veuillez entrer le processus que vous voulez surveillé : ") | |||
| def countdown(founded_process): | |||
| heure_depart = time.time() | |||
| print("Chronometre en marche !") | |||
| print("Process surveillé : " + str(founded_process)) | |||
| print("Heure de départ (Secondes): " + str( int(heure_depart) )) | |||
| while catch_process(searching_process) != None : | |||
| print("En attente de fermeture") | |||
| heure_arret = time.time() | |||
| uptime_process = int(heure_arret) - int(heure_depart) | |||
| heures = 0 | |||
| minutes = 0 | |||
| secondes = 0 | |||
| #Dictionnaire pour une prochaine mise à jour | |||
| process = ["firefox.exe", "discord.exe"] | |||
| while uptime_process > 3600 : | |||
| uptime_process = uptime_process - 3600 | |||
| heures += 1 | |||
| if heures < 10 : | |||
| heures = '0' + str(heures) | |||
| while uptime_process > 60 : | |||
| minutes += 1 | |||
| uptime_process = uptime_process - 60 | |||
| def get_time(): | |||
| now = datetime.now().time() | |||
| print("now =", now) | |||
| if minutes < 10 : | |||
| minutes = '0' + str(minutes) | |||
| secondes = uptime_process | |||
| if secondes < 10 : | |||
| secondes = '0' + str(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","Uptime du processus : %s:%s:%s " % (heures, minutes, secondes)) | |||
| date = datetime.today().strftime('%d-%m-%Y') | |||
| f = open("logs.txt", "a") | |||
| f.write(date + " | Programme : " + searching_process + " | Uptime du processus : %s:%s:%s " % (heures, minutes, secondes)) | |||
| f.close() | |||
| def main(): | |||
| searching_process = "nothing.exe" | |||
| toaster.show_toast("NoSocialLife Counter","Programme recherché : " + searching_process ) | |||
| i = 0 | |||
| process_running = False | |||
| delay = 1 | |||
| delay = 10 | |||
| founded_process = catch_process(searching_process) | |||
| if founded_process != None : | |||
| print("Le processus recherché à été trouvé!") | |||
| process_running = True | |||
| while process_running == False : | |||
| founded_process = catch_process(searching_process) | |||
| print("Etat de la recherche : " + founded_process) | |||
| get_time() | |||
| time.sleep(delay) | |||
| i += 1 | |||
| print("Etat de la recherche : " + str(founded_process)) | |||
| if founded_process != None : | |||
| print("PROCESS TROUVE !") | |||
| process_running = True | |||
| time.sleep(1) | |||
| countdown(founded_process) | |||
| def catch_process(searching_process): | |||
| @@ -37,7 +87,6 @@ def catch_process(searching_process): | |||
| catched = True | |||
| if catched == False : | |||
| print("Programme non trouvé") | |||
| founded_process = None | |||
| return founded_process | |||
| @@ -46,4 +95,5 @@ if __name__ == '__main__': | |||
| try : | |||
| main() | |||
| except : | |||
| print("Erreur, Redemarrage du script") | |||
| main() | |||