From ab5b87405132153bd837139f452cf8020d821cec Mon Sep 17 00:00:00 2001 From: Derisis13 Date: Thu, 9 Dec 2021 22:50:37 +0100 Subject: [PATCH] -d and --backup-dir options completed --- main.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index db978ac..8112bf2 100644 --- a/main.py +++ b/main.py @@ -31,35 +31,36 @@ def save_settings(): def restore(): - # todo + return # todo if __name__ == '__main__': - backupdir = "/home/lacko/.backup" + backupdir = os.path.expanduser("~/.backup") try: options, values = getopt.getopt(sys.argv[1:], "hd:r", ["help", "backup-dir=", "restore"]) except getopt.GetoptError as err: print("Error: ", err.msg) exit(1) for option, value in options: - if option in ("h", "help"): + if option in ("-h", "help"): print("usage: [opts]\n\ Options:\n\ \t-h --help: show this\n\ \t-d --backup-dir [directory]: set the directory for the backup/restoration (default is ~/.backups)\n\ \t-r --restore: run the restoration (from backupdir)\n") # todo: exit() - elif option in("d", "backup-dir"): - backupdir = value - elif option in("r", "restore"): + elif option in ("-d", "backup-dir"): + backupdir = os.path.expanduser(value) + elif option in ("-r", "restore"): restore() exit() try: - # os.chdir("/run/user/1000/gvfs/smb-share:server=ds_panni.local,share=lacko/Backup/T490") os.chdir(backupdir) except FileNotFoundError: subprocess.call(["mkdir", backupdir]) + os.chdir(backupdir) + run_daily() list_pkgs() save_settings()