mirror of
https://github.com/Derisis13/barusu.git
synced 2025-12-07 03:52:48 +01:00
Added argument processing
This commit is contained in:
30
main.py
30
main.py
@@ -2,6 +2,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
|
import getopt
|
||||||
|
|
||||||
|
|
||||||
def run_daily():
|
def run_daily():
|
||||||
@@ -29,14 +30,31 @@ def save_settings():
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
def restore():
|
||||||
|
# todo
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
for i in sys.argv:
|
|
||||||
if i == "--help" or i == "-h":
|
|
||||||
print("usage: <name> [opts]\n\
|
|
||||||
Options:\n\
|
|
||||||
\t-h --help: show this\n\
|
|
||||||
\t-d --backup-dir [directory]: set the directory the backups go to")
|
|
||||||
backupdir = "/home/lacko/.backup"
|
backupdir = "/home/lacko/.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"):
|
||||||
|
print("usage: <name> [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: <name>
|
||||||
|
exit()
|
||||||
|
elif option in("d", "backup-dir"):
|
||||||
|
backupdir = value
|
||||||
|
elif option in("r", "restore"):
|
||||||
|
restore()
|
||||||
|
exit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# os.chdir("/run/user/1000/gvfs/smb-share:server=ds_panni.local,share=lacko/Backup/T490")
|
# os.chdir("/run/user/1000/gvfs/smb-share:server=ds_panni.local,share=lacko/Backup/T490")
|
||||||
os.chdir(backupdir)
|
os.chdir(backupdir)
|
||||||
|
|||||||
Reference in New Issue
Block a user