-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging-test.py
71 lines (58 loc) · 2.03 KB
/
logging-test.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import argparse
import logging
from test_class_for_logging import Test
def main(backup_dir, source_dir, dest_dir, log):
logging.basicConfig(
format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
datefmt='%Y-%m-%d:%H:%M:%S',
level=logging.DEBUG)
# this is for turning off the logging
if log == "on":
logging.getLogger().disabled = False
elif log == "off":
logging.getLogger().disabled = True
else:
print(log)
raise ValueError("log option is not valid. on or off")
logging.info('backup-dir')
print(backup_dir)
logging.info('source-dir')
print(source_dir)
logging.info('dest-dir')
print(dest_dir)
start = Test(backup_dir, source_dir, dest_dir)
out = start.print_out()
print(out)
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Python scripts for doing the rsync link-dest job")
parser.add_argument('-b',
'--backup_dir',
action='store',
type=str,
required=True,
help="backup-dir",
)
parser.add_argument('-s',
'--source_dir',
action='store',
type=str,
required=True,
help='source-dir',
)
parser.add_argument('-d',
'--dest_dir',
action='store',
type=str,
required=True,
help='dest-dir',
)
parser.add_argument('-l',
'--log',
action='store',
type=str,
default="on",
help='boolean for logging',
)
args = parser.parse_args()
main(args.backup_dir, args.source_dir, args.dest_dir, args.log)