示例#1
0
    for i in data:
        outputs[str(i['pin'])] = gpio(i['pin'], i['name'], "none", 'out')
        
    # Get inputs and set them up
    cur.execute("SELECT name, pin, type FROM inputs")
    data = cur.fetchall()
    for i in data:
        inputs[int(i['pin'])] = gpio(i['pin'], i['name'], i['type'], 'in')
    
    # Get events and set them up
    cur.execute("SELECT id FROM events")
    eventsdata = cur.fetchall()
    for i in eventsdata:
        events[int(i['id'])] = event(int(i['id']), cur)

sensors = sensors()

class WebSocket(tornado.websocket.WebSocketHandler):
    # Handle a new web client
    def open(self):
        clients.append(self)
        gui.console("Websocket Opened")

    def on_message(self, message):
        gui.console(message)
        args = message.split(":")
        # Create a new output (pin, name)
        if args[0] == "newoutput":
            if args[1] in outputs:
                self.write_message("error:GPIO already setup on pin " + args[1])
            else:
示例#2
0
                globals.inputs[i].stop_input_idle()
        try:
            sensors.temp_process.terminate()
        except AttributeError:
            pass
        sensors.run_sensor_refresh = False
        GPIO.cleanup()
        if not globals.nogui:
            gui.end()
        os.remove('/etc/homeremote/lock.pid')
        sys.exit(0)

if __name__ == "__main__":
    globals.init_globals()
    globals.security = security()
    globals.sensors = sensors()

    daemonize = False
    for i in sys.argv:
        if i == "-nogui":
            globals.nogui = True
        if i == "-D":
            daemonize = True
            globals.nogui = True

    if not globals.nogui:
        gui.start()
    if daemonize:
        gui.no_output = True

    # Check for a user on the database. If there isnt one, create a default admin account