-
-
Notifications
You must be signed in to change notification settings - Fork 388
/
manager.py
47 lines (39 loc) · 1.74 KB
/
manager.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
import argparse
from plotmanager.library.utilities.exceptions import InvalidArgumentException
from plotmanager.library.utilities.commands import start_manager, stop_manager, view, json_output, analyze_logs
parser = argparse.ArgumentParser(description='This is the central manager for Swar\'s Chia Plot Manager.')
help_description = '''
There are a few different actions that you can use: "start", "restart", "stop", "view", "status", "json", and
"analyze_logs". "start" will start a manager process. If one already exists, it will display an error message.
"restart" will try to kill any existing manager and start a new one. "stop" will terminate the manager, but all
existing plots will be completed. "view" can be used to display an updating table that will show the progress of your
plots. Once a manager has started it will always be running in the background unless an error occurs. This field is
case-sensitive.
"analyze_logs" is a helper command that will scan all the logs in your log_directory to get your custom settings for
the progress settings in the YAML file.
'''
parser.add_argument(
dest='action',
type=str,
help=help_description,
)
args = parser.parse_args()
if args.action == 'start':
start_manager()
elif args.action == 'restart':
stop_manager()
start_manager()
elif args.action == 'stop':
stop_manager()
elif args.action == 'view':
view()
elif args.action == 'json':
json_output()
elif args.action == 'status':
view(loop=False)
elif args.action == 'analyze_logs':
analyze_logs()
else:
error_message = 'Invalid action provided. The valid options are "start", "restart", "stop", "view", "status", "json" and ' \
'"analyze_logs".'
raise InvalidArgumentException(error_message)