From 09d6dd479e62372badb4684c5718038f72198295 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 31 Aug 2011 23:49:52 +0200 Subject: //god/Reaktor: initial commit --- god/Reaktor | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 god/Reaktor (limited to 'god/Reaktor') diff --git a/god/Reaktor b/god/Reaktor new file mode 100755 index 00000000..54bc5099 --- /dev/null +++ b/god/Reaktor @@ -0,0 +1,22 @@ +#! /usr/bin/env python + +import socket +from struct import unpack + +listen_address = '0.0.0.0' +listen_port = 2342 + +# create udp socket +mysocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + +# allow send/recieve from broacast address +mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1) + +# allow the socket to be re-used +mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) +mysocket.bind((listen_address, listen_port)) + +while True: + dev, state = unpack('BB', mysocket.recv(2)) + print "dev: " + str(dev) + print "state: " + str(state) -- cgit v1.2.3 From 30a52fcf18f073e65c81811e1fe93c87bf1cdd54 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 1 Sep 2011 00:31:07 +0200 Subject: Reaktor: add shackspace map --- god/Reaktor | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) (limited to 'god/Reaktor') diff --git a/god/Reaktor b/god/Reaktor index 54bc5099..47d2d7c9 100755 --- a/god/Reaktor +++ b/god/Reaktor @@ -1,11 +1,36 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 +# coding=UTF-8 +location = 'shackspace' +host = '0.0.0.0' +port = 2342 + +map = { + 'shackspace': { + 'device': { + 0: 'Licht0, Tensau\'s Kuschelecke; Fenster', + 1: 'Licht1, Sofaecke; Fenster', + 2: 'Licht2, Tensau\'s Kuschelecke; Ghetto', + 3: 'Licht3, Sofaecke; Ghetto', + 4: 'Licht4, Richtung Getränkelager', + 5: 'Licht5, Porschekonsole', + 6: 'Licht6, Tomatenecke', + 7: 'Licht7, Ghetto', + 10: 'Hauptschalter' + }, + 'state': { + 0: 'aus', + 1: 'an', + 2: 'aus in T-10s' + }, + '->': 'ist' + } +} + import socket +from string import join from struct import unpack -listen_address = '0.0.0.0' -listen_port = 2342 - # create udp socket mysocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -14,9 +39,12 @@ mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1) # allow the socket to be re-used mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) -mysocket.bind((listen_address, listen_port)) +mysocket.bind((host, port)) + +map = map[location] while True: - dev, state = unpack('BB', mysocket.recv(2)) - print "dev: " + str(dev) - print "state: " + str(state) + did, sid = unpack('BB', mysocket.recv(2)) + device, state = map['device'][did], map['state'][sid] + arrow = map['->'] + print join([device, arrow, state], ' ') -- cgit v1.2.3 From 5e7bbf0c4b53a73e3f0bb7e53cbd8bb97c3187cd Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 1 Sep 2011 01:52:31 +0200 Subject: Reaktor: Tensau's Ecke ist die Zickenzone --- god/Reaktor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'god/Reaktor') diff --git a/god/Reaktor b/god/Reaktor index 47d2d7c9..9708d9bc 100755 --- a/god/Reaktor +++ b/god/Reaktor @@ -8,9 +8,9 @@ port = 2342 map = { 'shackspace': { 'device': { - 0: 'Licht0, Tensau\'s Kuschelecke; Fenster', + 0: 'Licht0, Zickenzone; Fenster', 1: 'Licht1, Sofaecke; Fenster', - 2: 'Licht2, Tensau\'s Kuschelecke; Ghetto', + 2: 'Licht2, Zickenzone; Ghetto', 3: 'Licht3, Sofaecke; Ghetto', 4: 'Licht4, Richtung Getränkelager', 5: 'Licht5, Porschekonsole', -- cgit v1.2.3 From 4fb37da707279faf92cc8a054c646336f23dfdbe Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 1 Sep 2011 02:20:34 +0200 Subject: //god/Reaktor/index: initial commit This wrapper script downloads and configures jsonbot as necessary. --- god/Reaktor | 50 --------------------------------------------- god/Reaktor/index | 36 ++++++++++++++++++++++++++++++++ god/Reaktor/lib/listener.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 50 deletions(-) delete mode 100755 god/Reaktor create mode 100755 god/Reaktor/index create mode 100755 god/Reaktor/lib/listener.py (limited to 'god/Reaktor') diff --git a/god/Reaktor b/god/Reaktor deleted file mode 100755 index 9708d9bc..00000000 --- a/god/Reaktor +++ /dev/null @@ -1,50 +0,0 @@ -#! /usr/bin/env python2 -# coding=UTF-8 - -location = 'shackspace' -host = '0.0.0.0' -port = 2342 - -map = { - 'shackspace': { - 'device': { - 0: 'Licht0, Zickenzone; Fenster', - 1: 'Licht1, Sofaecke; Fenster', - 2: 'Licht2, Zickenzone; Ghetto', - 3: 'Licht3, Sofaecke; Ghetto', - 4: 'Licht4, Richtung Getränkelager', - 5: 'Licht5, Porschekonsole', - 6: 'Licht6, Tomatenecke', - 7: 'Licht7, Ghetto', - 10: 'Hauptschalter' - }, - 'state': { - 0: 'aus', - 1: 'an', - 2: 'aus in T-10s' - }, - '->': 'ist' - } -} - -import socket -from string import join -from struct import unpack - -# create udp socket -mysocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - -# allow send/recieve from broacast address -mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1) - -# allow the socket to be re-used -mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) -mysocket.bind((host, port)) - -map = map[location] - -while True: - did, sid = unpack('BB', mysocket.recv(2)) - device, state = map['device'][did], map['state'][sid] - arrow = map['->'] - print join([device, arrow, state], ' ') diff --git a/god/Reaktor/index b/god/Reaktor/index new file mode 100755 index 00000000..6470298e --- /dev/null +++ b/god/Reaktor/index @@ -0,0 +1,36 @@ +#! /bin/sh +# +# //god/Reaktor - listen to UDP events and forward them to IRC +# +# export host passwd printto to configure jsb-udp +# +set -euf +cd $(readlink -f $(dirname $0)) + +listener=$(readlink -f lib/listener.py) + +jsb_version=0.7.1.2 +distdir=jsb-$jsb_version.tar.gz + +host=${host-91.206.142.247} +passwd=${passwd-h4x0r} +printto=${printto-#shackspace} + +if ! test -x tmp/jsb-$jsb_version; then + mkdir -p tmp + cd tmp + curl -f http://jsonbot.googlecode.com/files/jsb-$jsb_version.tar.gz | tar zx + cd jsb-$jsb_version + bin/jsb-udp -s ': 'ist' + } +} + +import socket +from string import join +from struct import unpack + +# create udp socket +mysocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + +# allow send/recieve from broacast address +mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1) + +# allow the socket to be re-used +mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) +mysocket.bind((host, port)) + +map = map[location] + +while True: + did, sid = unpack('BB', mysocket.recv(2)) + device, state = map['device'][did], map['state'][sid] + arrow = map['->'] + print join([device, arrow, state], ' ') -- cgit v1.2.3 From e28303fa10c603fe61991b27e1202c5d97134dd4 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 1 Sep 2011 10:54:15 +0200 Subject: //god/Reaktor: add TODO --- god/Reaktor/index | 1 + 1 file changed, 1 insertion(+) (limited to 'god/Reaktor') diff --git a/god/Reaktor/index b/god/Reaktor/index index 6470298e..a2e6fe61 100755 --- a/god/Reaktor/index +++ b/god/Reaktor/index @@ -33,4 +33,5 @@ sed -i ' s/^printto *=.*/printto="'$printto'"/ ' config/udp-send +# TODO output modules: stderr, jsb-udp, remount-ro, ... PYTHONUNBUFFERED=y $listener | tee /dev/stderr | bin/jsb-udp -- cgit v1.2.3