From 818f53b1d4de38bfe07ccb86b6b13ef8547ee6b2 Mon Sep 17 00:00:00 2001 From: tosca07 <34959043+tosca07@users.noreply.github.com> Date: Mon, 20 May 2024 18:08:28 +0200 Subject: [PATCH] Check if dropbox games folder integration exists In case Drupebox (dropbox folder sychnronization) has been installed the sync process is called when shutting down/exiting or rebooting picochess --- utilities.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/utilities.py b/utilities.py index 47f5a788..78e32781 100644 --- a/utilities.py +++ b/utilities.py @@ -39,7 +39,7 @@ from typing import Optional # picochess version -version = '3.3' +version = '3.2' evt_queue: queue.Queue = queue.Queue() dispatch_queue: queue.Queue = queue.Queue() @@ -237,7 +237,13 @@ def update_picochess(dgtpi: bool, auto_reboot: bool, dgttranslate: DgtTranslate) def shutdown(dgtpi: bool, dev: str): """Shutdown picochess.""" logging.debug('shutting down system requested by (%s)', dev) - time.sleep(5) # give some time to send out the pgn file or speak the event + + try: + subprocess.run(['python3', 'home/pi/drupebox/drupebox.py']) + except FileNotFoundError: + pass + + time.sleep(10) # give some time to send out the pgn file or speak the event if platform.system() == 'Windows': os.system('shutdown /s') elif dgtpi: @@ -251,7 +257,12 @@ def shutdown(dgtpi: bool, dev: str): def exit(dgtpi: bool, dev: str): """exit picochess.""" logging.debug('exit picochess requested by (%s)', dev) - time.sleep(5) # give some time to send out the pgn file or speak the event + try: + subprocess.run(['python3', '/home/pi/drupebox/drupebox.py']) + except FileNotFoundError: + pass + + time.sleep(10) # give some time to send out the pgn file or speak the event if platform.system() == 'Windows': os.system('sudo pkill -f chromium') os.system('sudo systemctl stop picochess') @@ -270,7 +281,11 @@ def exit(dgtpi: bool, dev: str): def reboot(dgtpi: bool, dev: str): """Reboot picochess.""" logging.debug('rebooting system requested by (%s)', dev) - time.sleep(5) # give some time to send out the pgn file or speak the event + try: + subprocess.run(['python3', '/home/pi/drupebox/drupebox.py']) + except FileNotFoundError: + pass + time.sleep(10) # give some time to send out the pgn file or speak the event if platform.system() == 'Windows': os.system('shutdown /r') elif dgtpi: