-
Notifications
You must be signed in to change notification settings - Fork 0
/
backupnowcmd.py
executable file
·52 lines (42 loc) · 1.24 KB
/
backupnowcmd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
"""
Manage an rsync operation.
"""
import sys
from backupnow.rsync import RSync
if sys.version_info.major >= 3:
from tkinter import messagebox
else:
import tkMessageBox as messagebox # type: ignore
def changed(progress, message=None, error=None):
print("changed({}, message=\"{}\", error=\"{}\")"
"".format(progress, message, error))
def main():
if len(sys.argv) > 3:
messagebox.showerror(
"Error",
"Expected only source&destination but got {}".format(sys.argv[1:])
)
try:
in_folder = sys.argv[1]
out_folder = sys.argv[2]
except IndexError:
clause = ", but there were none."
if len(sys.argv) > 1:
clause = ", but there was only {}".format(sys.argv[1:])
messagebox.showerror(
"Error",
"There must be both a source and a destination parameter"+clause
)
return 1
rsync = RSync()
code = rsync.run(in_folder, out_folder)
# code = result['code']
if code == 0:
print("rsync completed without any errors.")
else:
print("rsync failed (code {}).".format(code))
return code
return 0
if __name__ == "__main__":
sys.exit(main())