forked from OpenRoberta/robertalab-ev3dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openrobertalab
49 lines (35 loc) · 1.01 KB
/
openrobertalab
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
#!/usr/bin/env python3
import atexit
import logging
import os
import sys
from gi.repository import GLib
from dbus.mainloop.glib import DBusGMainLoop
# prefer the module updated from the server
# the regular place where pip3 would install then would be
# ~/.local/lib/python3.7/site-packages
local_pkg_path = os.path.expanduser('~/.local/lib/python')
os.makedirs(local_pkg_path, exist_ok=True)
sys.path.insert(0, local_pkg_path)
from roberta.lab import Service
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('roberta')
service = None
def cleanup():
global service
if service:
service.hal.clearDisplay()
service.hal.stopAllMotors()
logger.info('--- done ---')
logging.shutdown()
def main():
global service
logger.info('--- starting ---')
atexit.register(cleanup)
DBusGMainLoop(set_as_default=True)
loop = GLib.MainLoop()
service = Service('/org/openroberta/Lab1')
logger.debug('loop running')
loop.run()
if __name__ == "__main__":
main()