示例#1
0
文件: model.py 项目: stevenleigh/sib
	def load_all_config(self):
		if DEBUG:
			t = threading.current_thread();
			print("{0}: Loading SIB configuration".format(t))
		socketio.send(self.conn, GET_CONFIG)
		config_str = socketio.receive(self.conn)
		if DEBUG:
			print("-------------------------------------------------------------------")
			print(config_str)
			print("-------------------------------------------------------------------")
		self.config = json.loads(config_str)
示例#2
0
文件: model.py 项目: stevenleigh/sib
 def load_all_config(self):
     if DEBUG:
         t = threading.current_thread()
         print("{0}: Loading SIB configuration".format(t))
     socketio.send(self.conn, GET_CONFIG)
     config_str = socketio.receive(self.conn)
     if DEBUG:
         print(
             "-------------------------------------------------------------------"
         )
         print(config_str)
         print(
             "-------------------------------------------------------------------"
         )
     self.config = json.loads(config_str)
示例#3
0
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)

while True:
    conn, addr = s.accept()
    print('Connected by', addr)

    settings_file = open(CONFIG_FILE, 'r')
    contents = settings_file.read()
    settings_file.close()

    config = json.loads(contents)

    while True:
        data = socketio.receive(conn)
        if not data:
            break
        print("received:{0}".format(data))
        if data == GET_CONFIG:
            print("received send all config command")
            socketio.send(conn, contents)
        if data == SET_CONFIG:
            print("received set config command")
            page = socketio.receive(conn)
            key = socketio.receive(conn)
            value = socketio.receive(conn)
            print("Received page:{0} key:{1} value:{2}".format(
                page, key, value))
            config['SETTINGS'][page][key] = json.loads(value)
            settings_file = open(CONFIG_FILE, 'w')
示例#4
0
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)

while True:
    conn, addr = s.accept()
    print("Connected by", addr)

    settings_file = open(CONFIG_FILE, "r")
    contents = settings_file.read()
    settings_file.close()

    config = json.loads(contents)

    while True:
        data = socketio.receive(conn)
        if not data:
            break
        print("received:{0}".format(data))
        if data == GET_CONFIG:
            print("received send all config command")
            socketio.send(conn, contents)
        if data == SET_CONFIG:
            print("received set config command")
            page = socketio.receive(conn)
            key = socketio.receive(conn)
            value = socketio.receive(conn)
            print("Received page:{0} key:{1} value:{2}".format(page, key, value))
            config["SETTINGS"][page][key] = json.loads(value)
            settings_file = open(CONFIG_FILE, "w")
            settings_file.write(json.dumps(config, sort_keys=True, indent=4, separators=(",", ": ")))