예제 #1
0
파일: web.py 프로젝트: vhn0912/PyPilot
    def background_thread(self):
        print('processing clients')
        x = 0
        while True:
            socketio.sleep(.25)
            sys.stdout.flush()  # update log
            sids = list(self.clients)
            for sid in sids:
                if not sid in self.clients:
                    print('client was removed')
                    continue  # was removed

                client = self.clients[sid]
                values = client.list_values()
                if values:
                    #print('values', values)
                    socketio.emit('pypilot_values',
                                  pyjson.dumps(values),
                                  room=sid)
                if not client.connection:
                    socketio.emit('pypilot_disconnect', room=sid)
                msgs = client.receive()
                if msgs:
                    # convert back to json (format is nicer)
                    socketio.emit('pypilot', pyjson.dumps(msgs), room=sid)
예제 #2
0
파일: hat.py 프로젝트: stelian42/pypilot
 def write_config(self):
     try:
         f = open(self.configfilename, 'w')
         f.write(pyjson.dumps(self.config) + '\n')
         f.close()
     except IOError:
         print('failed to save config file:', self.configfilename)