summaryrefslogtreecommitdiff
path: root/bot_backend.py
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2013-06-20 16:59:41 +0000
committerroot <root@beaglebone.local.sublab.org>2013-06-20 16:59:41 +0000
commit0ab0cbbda438fd30f24273f1db99d76746108a75 (patch)
tree8e83946a81a53a19b74082b708458a207e355624 /bot_backend.py
parent2debbb0e92d49ce43677e66794a76ca7749e8fc4 (diff)
bot_backend: use temporary HTTP API
Diffstat (limited to 'bot_backend.py')
-rw-r--r--bot_backend.py24
1 files changed, 6 insertions, 18 deletions
diff --git a/bot_backend.py b/bot_backend.py
index adf52a8..b1ccb48 100644
--- a/bot_backend.py
+++ b/bot_backend.py
@@ -1,4 +1,4 @@
-import liblo
+import contextlib
import urllib2
# Known lights, terminal symbols
@@ -6,7 +6,7 @@ lights_terminal = {}
for i in range(1,12):
ident = '%02d' % i
- lights_terminal[ident] = 'osc.udp://172.22.83.5:4243/dali/lamps/%s/bright' % ident
+ lights_terminal[ident] = 'http://beaglebone.local.sublab.org/set?%s=' % (i + 0x440)
# Production Rules/Aliases
lights_production = {
@@ -27,19 +27,9 @@ lights_production = {
u'hacklab': [u'hacklab-east-outer', u'hacklab-east-middle', u'hacklab-west-inner'],
}
-class OSCMessage(object):
- def __init__(self, url):
- parsed = urllib2.urlparse.urlparse(url)
- self.path = parsed.path
- self.url = urllib2.urlparse.urlunparse((parsed.scheme, parsed.netloc, '', '', '', ''))
-
- self.msg = liblo.Message(self.path)
-
- def __getattr__(self, name):
- return getattr(self.msg, name)
-
- def send(self):
- liblo.send(self.url, self.msg)
+def tmp_set(url, value):
+ with contextlib.closing(urllib2.urlopen(url + str(value))):
+ pass
def on_pubmsg(self, c, e):
message = e.arguments[0]
@@ -97,9 +87,7 @@ def on_light_set(self, tokens):
return
for light in lights:
- msg = OSCMessage(lights_terminal[light])
- msg.add(status)
- msg.send()
+ tmp_set(lights_terminal[light], status)
self.connection.privmsg(self.channel, "Light command processed.")
def light_usage(self):