def onMessage(self, msg, binary): if not binary: global msgList #self.factory.broadcast("'%s' from %s" % (msg, self.peerstr)) self.factory.broadcast(msg) command = msg print command if 'comstar|hvac' in command: command = command.split('|')[1] comports.serialWrite('comstar|'+hvacRCS.webToRCS(command)) elif 'audioa|getStatus' in command: audioauthority.makeCommand(command.split('.')[1], bracket=')') else: comports.serialWrite(command) command = ''
def run(self): x = 1 comBuffer = [] comQueue = [] while x is 1 : #fromlutron = lutron.read() fromlutron = comports.com['lutron'].read() if fromlutron != '': #print fromhvac if '\r' not in fromlutron: comBuffer.append(fromlutron) else: try: x = 0 comQueue.append(comBuffer) b = comQueue.pop() data = ''.join(b) if '\n' in data: data = data.replace('\n', '') print data if '~DEVICE' in data: try: if data in lutronForwards: comports.serialWrite(config.get('lutron', data)) except: print 'Something is wrong' raise else: pass except: if lutronRead().isAlive(): print 'thread still alive' else: print 'thread dead' lutronRead().start() raise finally: comBuffer = [] x = 1