forked from aaronwmorris/indi-allsky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
executable file
·67 lines (54 loc) · 1.79 KB
/
config.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
#!/usr/bin/env python3
import argparse
import logging
from indi_allsky.config import IndiAllSkyConfigUtil
logger = logging.getLogger('indi_allsky')
logger.setLevel(logging.INFO)
LOG_FORMATTER_STREAM = logging.Formatter('%(asctime)s [%(levelname)s] %(processName)s %(module)s.%(funcName)s() [%(lineno)d]: %(message)s')
LOG_HANDLER_STREAM = logging.StreamHandler()
LOG_HANDLER_STREAM.setFormatter(LOG_FORMATTER_STREAM)
logger.addHandler(LOG_HANDLER_STREAM)
if __name__ == "__main__":
argparser = argparse.ArgumentParser()
argparser.add_argument(
'action',
help='configuration management actions',
choices=(
'bootstrap', # load initial config
'list', # list configs
'load', # load exported config
'dump', # export config to STDOUT
'update_level', # update config functional level
'edit', # edit config in cli
'revert', # revert to an older config --id
'user_count', # return count of active users to STDOUT
'flush', # deletes all configs
),
)
argparser.add_argument(
'--config',
'-c',
help='config file',
type=argparse.FileType('r'),
)
argparser.add_argument(
'--id',
'-i',
help='config id (revert/dump)',
type=int,
)
argparser.add_argument(
'--force',
help='force changes',
dest='force',
action='store_true',
)
argparser.set_defaults(force=False)
args = argparser.parse_args()
iacu = IndiAllSkyConfigUtil()
action_func = getattr(iacu, args.action)
action_func(
config=args.config,
config_id=args.id,
force=args.force,
)