-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathudi-av-poly.py
55 lines (48 loc) · 1.51 KB
/
udi-av-poly.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
#!/usr/bin/env python3
"""
This is a NodeServer template for Polyglot v2 written in Python2/3
by Einstein.42 (James Milne) [email protected]
"""
import udi_interface
import sys
from nodes import AVController
"""
Import the polyglot interface module. This is in pypy so you can just install it
normally. Replace pip with pip3 if you are using python3.
Virtualenv:
pip install udi_interface
Not Virutalenv:
pip install udi_interface --user
*I recommend you ALWAYS develop your NodeServers in virtualenv to maintain
cleanliness, however that isn't required. I do not condone installing pip
modules globally. Use the --user flag, not sudo.
"""
LOGGER = udi_interface.LOGGER
"""
udi_interface has a LOGGER that is created by default and logs to:
logs/debug.log
You can use LOGGER.info, LOGGER.warning, LOGGER.debug, LOGGER.error levels as needed.
"""
if __name__ == "__main__":
try:
polyglot = udi_interface.Interface([])
"""
Instantiates the Interface to Polyglot.
"""
polyglot.start('3.0.0')
"""
Starts MQTT and connects to Polyglot.
"""
AVController(polyglot, 'controller', 'controller', 'AVRECEIVER')
"""
Creates the Controller Node and passes in the Interface
"""
polyglot.runForever()
"""
Sits around and does nothing forever, keeping your program running.
"""
except (KeyboardInterrupt, SystemExit):
"""
Catch SIGTERM or Control-C and exit cleanly.
"""
sys.exit(0)