Few improvements of loops

made the while loops simpler
This commit is contained in:
TheGoldenMine 2023-02-02 14:21:07 +02:00 committed by GitHub
parent 0caeb6882f
commit 5313e150a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,10 +124,10 @@ def main(webhook_url: str) -> None:
thread_timer_killer.join(120) thread_timer_killer.join(120)
if thread_timer_killer.is_alive(): if thread_timer_killer.is_alive():
e.set() e.set()
while True: while thread_timer_killer.is_alive():
if not thread_timer_killer.is_alive(): continue
main.driver.service.process.send_signal(SIGTERM) main.driver.service.process.send_signal(SIGTERM)
break
try: try:
os.remove('discord_gift.png') os.remove('discord_gift.png')
except BaseException: except BaseException:
@ -186,8 +186,8 @@ if __name__ == "__main__":
confir = Write.Input( confir = Write.Input(
"[*] Do you want to use a Discord Webhook URL ? [y/n] -> ", "[*] Do you want to use a Discord Webhook URL ? [y/n] -> ",
Colors.green_to_cyan, Colors.green_to_cyan,
interval=0.01) interval=0.01).lower()
if (confir == YES) or (confir == YES.upper()): if confir == "yes" or confir == "y":
th_main = Thread( th_main = Thread(
target=main, target=main,
args=( args=(
@ -195,7 +195,7 @@ if __name__ == "__main__":
Colors.green_to_cyan, Colors.green_to_cyan,
interval=0.01), interval=0.01),
)) ))
elif (confir == NO) or (confir == NO.upper()): elif confir == "no" or confir == "n":
th_main = Thread(target=main, args=(None,)) th_main = Thread(target=main, args=(None,))
else: else:
raise SystemExit(Write.Print( raise SystemExit(Write.Print(
@ -203,8 +203,7 @@ if __name__ == "__main__":
Colors.yellow_to_green)) Colors.yellow_to_green))
Thread(target=pystray_icon).start() Thread(target=pystray_icon).start()
th_main.start() th_main.start()
while True: while th_main.is_alive():
if not th_main.is_alive():
pystray_icon.icon.stop()
break
time.sleep(SLEEP_TIME) time.sleep(SLEEP_TIME)
pystray_icon.icon.stop()