import pango
+class Switches:
+ def __init__(self):
+ self.misc_input = 0xff
+ self.switch_input = 0x3f
+ def door_open(self):
+ return self.switch_input & 0x20
+ def set_door_open(self, open = True):
+ if open:
+ self.switch_input |= 0x20
+ else:
+ self.switch_input &= ~0x20
+
#now we have both gtk and gtk.glade imported
#Also, we know we are running GTK v2
self.vendpw = "AAAAAAAAAAAAAAAA"
self.messageid = None
+ self.switches = Switches()
#s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
self.do_send('2'+key+' keypress\n')
def door_changed(self, widget):
- print 'Door changed to', widget.pressed()
- pass
+ self.switches.set_door_open(not widget.get_active())
+ if widget.get_active():
+ self.do_send('401 door closed\n')
+ else:
+ self.do_send('400 door open\n')
def handleNewConnection(self,source,condition):
#source is a socket in GTK v 1 and a fd in version 2
gtk.input_remove(tag)
conn.close()
self.sock.close()
+ self.sock.shutdown()
gtk.mainquit()
sys.stdout.write("quit!\n")