-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
pycozmo_app.py
executable file
·46 lines (35 loc) · 994 Bytes
/
pycozmo_app.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
#!/usr/bin/env python
"""
PyCozmo application.
"""
import sys
import time
import argparse
import pycozmo
def parse_args():
""" Parse command-line arguments. """
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("-v", "--verbose", action="store_true", help="verbose")
args = parser.parse_args()
return args
def main():
# Parse command-line.
args = parse_args() # noqa
try:
with pycozmo.connect(
log_level="DEBUG" if args.verbose else "INFO",
protocol_log_level="INFO",
robot_log_level="INFO") as cli:
brain = pycozmo.brain.Brain(cli)
brain.start()
while True:
try:
time.sleep(1.0)
except KeyboardInterrupt:
break
brain.stop()
except Exception as e:
print("ERROR: {}".format(e))
sys.exit(1)
if __name__ == '__main__':
main()