From e7cc303abdd8a0c7b427c44bb7549777805bfa05 Mon Sep 17 00:00:00 2001 From: Xargon Date: Sat, 21 May 2022 22:08:38 +0900 Subject: [PATCH] CLOUDSYNC: added arguments --- es_configs/es_systems.xml | 2 +- tools/cloud-sync.py | 42 ++++++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/es_configs/es_systems.xml b/es_configs/es_systems.xml index c55ae691..41f00e31 100644 --- a/es_configs/es_systems.xml +++ b/es_configs/es_systems.xml @@ -1410,7 +1410,7 @@ tools RetroDECK Tools /var/config/retrodeck/tools - .sh .SH .py .PY + .sh .SH bash %ROM% tools tools diff --git a/tools/cloud-sync.py b/tools/cloud-sync.py index ed6cf9c9..a0a03bb5 100644 --- a/tools/cloud-sync.py +++ b/tools/cloud-sync.py @@ -1,5 +1,7 @@ #!/usr/bin/python3 +# Original Script by https://gist.github.com/nullstalgia + import os import shutil import configparser @@ -38,9 +40,39 @@ if not os.path.exists(rclone_config_path): if not os.path.exists(rules_config_path): shutil.copyfile(rules_config_def_path, rules_config_path) -# sync states -#print("Syncing savestates") -#os.system(f"rclone bisync -v --workdir /var/cache/rclone/bisync {retrodeck_folder}/roms/ \"{sync_remote}\":\"{sync_path}/savestates\" --include *.state* --log-file {retrodeck_folder}/.logs/cloud-sync.log") +# parse the args and see if we want to upload or download +for opt, arg in opts: + if opt == ("-h", "--help"): + print (f "Usage:\n\ +flatpak run [FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ARGUMENTS]\n\ +\n\ +Arguments:\n\ + -h, --help Print this help\n\ + --reset Starts the initial RetroDECK installer (backup your data first!)\n\ + --reset-ra Resets RetroArch's config to the default values\n\ + --reset-sa Reset standalone emulator configs to the default values\n\ + --reset-tools Recreate the tools section\n\ +\n\ +https://retrodeck.net") + sys.exit() + elif opt in ("-u", "--upload"): -print("Syncing saves, screenshots, and gamedata") -os.system(f"rclone bisync -v --workdir /var/cache/rclone/bisync {retrodeck_folder}/roms/ \"{sync_remote}\":\"{sync_path}/\" --filters-file {rules_config_path} --log-file {retrodeck_folder}/.logs/cloud-sync.log") \ No newline at end of file + # upload states + #print("Syncing savestates") + #os.system(f"rclone sync -P {retrodeck_folder}/roms/ \"{sync_remote}\":\"{sync_path}/savestates\" --include *.state* --log-file {retrodeck_folder}/.logs/cloud-sync.log") + + # upload saves + os.system(f'zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --text=Uploading saves, screenshots, and gamedata.\n\nPress ok to continue and wait for the completion message.') + os.system(f"rclone sync -P {retrodeck_folder}/roms/ \"{sync_remote}\":\"{sync_path}/\" --filter-from {rules_config_path} --log-file {retrodeck_folder}/.logs/cloud-sync.log") + os.system(f'zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --text=Done!\n\nYou can check the logfiles in {retrodeck_folder}/.logs/cloud-sync.log') + + elif opt in ("-d", "--download"): + + # download states + #print("Syncing savestates") + #os.system(f"rclone sync -P \"{sync_remote}\":\"{sync_path}/savestates\" {retrodeck_folder}/roms/ --include *.state* --log-file {retrodeck_folder}/.logs/cloud-sync.log") + + # download saves + os.system(f'zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --text=Downloading saves, screenshots, and gamedata.\n\nPress ok to continue and wait for the completion message.') + os.system(f"rclone sync -P \"{sync_remote}\":\"{sync_path}/\" {retrodeck_folder}/roms/ --filter-from {rules_config_path} --log-file {retrodeck_folder}/.logs/cloud-sync.log") + os.system(f'zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --text=Done!\n\nYou can check the logfiles in {retrodeck_folder}/.logs/cloud-sync.log') \ No newline at end of file