/
main.py
88 lines (69 loc) · 1.87 KB
/
main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
logger.add(sys.stderr, level=logger_level[verbose]) # Add new logger back
@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(
"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, testing):
"""CLI command to run kiosk."""
kiosk.run(simulate, testing=testing)
@cli.command("demo")
@click.argument(
"name",
type=click.Choice([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(
"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, testing):
"""CLI command to run demo."""
demo.run(name, simulate, testing=testing)
@cli.command("test")
def run_test():
"""CLI command to run test."""
test.run()
if __name__ == "__main__":
cli()