-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
121 lines (100 loc) · 2.57 KB
/
main.py
File metadata and controls
121 lines (100 loc) · 2.57 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import sys
import click
from loguru import logger
from runners import demo, kiosk, test, utils
logger_level = ["ERROR", "WARNING", "SUCCESS", "INFO", "DEBUG", "TRACE"]
@click.group()
@click.option("-v", "--verbose", count=True)
def cli(verbose):
"""CLI group."""
if verbose >= len(logger_level):
print(f"Only {len(logger_level) - 1} verbose flags allowed.")
exit()
logger.remove() # Remove default logger
# Start up logger
logger.add(
"logs/sss.log",
rotation="00:00",
retention="1 week",
enqueue=True,
backtrace=True,
diagnose=True,
level=logger_level[verbose],
)
logger.info(" ____")
logger.info(" / . .\\")
logger.info(" \\ ---< Starting SSS")
logger.info(" \\ /")
logger.info(" __________/ /")
logger.info("-=:___________/")
@cli.command(name="simulator")
def run_simulator():
"""CLI command to run simulator."""
from runners import simulator # pylint: disable=import-outside-toplevel
simulator.run()
@cli.command(name="kiosk")
@click.option(
"-s",
"--simulate",
is_flag=True,
default=False,
help="Run in simulated environment.",
)
@click.option(
"-n",
"--new_hardware",
is_flag=True,
default=False,
help="Run on new hardware.",
)
@click.option(
"testing",
"-t",
"--test",
is_flag=True,
default=False,
help="Run in test mode. This shortens the demo time and user input time "
"for testing purposes.",
)
def run_kiosk(simulate, new_hardware, testing):
"""CLI command to run kiosk."""
kiosk.run(simulate, testing=testing, new_hardware=new_hardware)
@cli.command("demo")
@click.argument(
"name",
type=click.Choice(
sorted([name for name, _ in utils.get_demos()]), case_sensitive=False
),
)
@click.option(
"-s",
"--simulate",
is_flag=True,
default=False,
help="Run in simulated environment.",
)
@click.option(
"-n",
"--new_hardware",
is_flag=True,
default=False,
help="Run on new hardware.",
)
@click.option(
"testing",
"-t",
"--test",
is_flag=True,
default=False,
help="Run in test mode. This provides feedback for if your demo is "
"running fast enough relative to the set frame rate.",
)
def run_demo(name, simulate, new_hardware, testing):
"""CLI command to run demo."""
demo.run(name, simulate, new_hardware, testing=testing)
@cli.command("test")
def run_test():
"""CLI command to run test."""
test.run()
if __name__ == "__main__":
cli()