def cmd_by_deviceorcombs_data(cmd): # print("come in cmd_by_device_data") try: cmd_list = re.split(",|,| |;|;", cmd) dev_class_type = "" if len(cmd_list) == 1 or len(cmd_list) == 2 and cmd_list[0] != "": # combs_list=user.data_dict.get("combs",None) combs_list = user.get_data_dict("combs") control_name = cmd_list[0] dev_class_type = "combs" if combs_list: for cl in combs_list: if cl.get("control_name", None) == control_name: dev_class_type = "combs" else: # device_list=user.data_dict.get("devices",None) device_list = user.get_data_dict("devices") room_name = cmd_list[0] dev_name = cmd_list[1] if device_list: for dl in device_list: if dl.get("device_name", None) == dev_name and dl.get( "room_name", None) == room_name: dev_class_type = dl.get("dev_class_type") except Exception as e: logfile.logger.exception(e.message) finally: return dev_class_type, cmd_list
def update_addrs(self,index): # print("come in update_addrs") self.sipaddrcomboBox.clear() # friend_l=user.data_dict.get("usr",None) friend_l=user.get_data_dict("usr") if friend_l: if index==0: user.set_info_dict("PID","0002") for l in friend_l: if l.get("type",None)=="gateway": self.sipaddrcomboBox.addItem(l.get("friend")) elif index==1: user.set_info_dict("PID","0008") for l in friend_l: if l.get("type",None)=="mirror": self.sipaddrcomboBox.addItem(l.get("friend")) elif index==2: user.set_info_dict("PID","0003") for l in friend_l: if l.get("type",None)=="coordin_zigbee": self.sipaddrcomboBox.addItem(l.get("friend")) elif index==3: user.set_info_dict("PID","0001") for l in friend_l: if l.get("type",None)=="icool": self.sipaddrcomboBox.addItem(l.get("friend")) elif index==4: user.set_info_dict("PID","0004") for l in friend_l: if l.get("type",None)=="aqms": self.sipaddrcomboBox.addItem(l.get("friend")) else: QtGui.QMessageBox.about(self,"Info","no friends")
def display_combs(self): # print("come in display_combs") # combs_list=user.data_dict.get("combs",None) combs_list=user.get_data_dict("combs") self.combstextBrowser.clear() if combs_list: for cl in combs_list: control_name=cl.get("control_name") item=control_name if item: self.combstextBrowser.append(_fromUtf8(item))
def search_devices(self): self.ipcomboBox.clear() if self.username2lineEdit.text(): user.set_info_dict("USERNAME",str(self.username2lineEdit.text())) SearchDevice().search() devices_list=user.get_data_dict("search") if devices_list: dev_list=function.search_devices_by_type(devices_list) if dev_list: for l in dev_list: self.ipcomboBox.addItem(l.get("server_ip")) self.update_device_info(0) else: QtGui.QMessageBox.about(self,"Info",_fromUtf8("please filling in username"))
def update_device_info(self,index): # print("come in update device info") SERVER_IP=str(self.ipcomboBox.currentText()) user.set_info_dict("SERVER_IP",SERVER_IP) # print("server_ip===",user.get_info_dict("SERVER_IP")) user.set_info_dict("getHttp","http://{0}/lua/getall".format(SERVER_IP)) user.set_info_dict("postHttp","http://{0}/lua".format(SERVER_IP)) devices_list=user.get_data_dict("search") if devices_list: dev_list=function.search_devices_by_type(devices_list) device=dev_list[index] SERVER_PORT=device.get("server_port",None) if SERVER_PORT: user.set_info_dict("SERVER_PORT",SERVER_PORT) # print("server_port===", SERVER_PORT) data_length=device.get("data_length",None) if data_length: user.set_info_dict("data_length",data_length) # print("data_length===",data_length) SIPADDR=device.get("sip_addr",None) if SIPADDR: user.set_info_dict("SIPADDR",SIPADDR)
def display_devices(self): # print("come in display_devices") # device_list=user.data_dict.get("devices",None) device_list=user.get_data_dict("devices") # print(device_list) self.devlisttextBrowser.clear() if device_list: dev_list_by_type,class_types=function.dev_by_classtype(device_list) # print(dev_list_by_type) # print(class_types) if class_types: for c in class_types: for d in dev_list_by_type: if d.get(c,None): cm=c+":" self.devlisttextBrowser.append(_fromUtf8(cm)) temp_list=d.get(c) for tl in temp_list: if tl: item=','.join(tl) item=" "+item self.devlisttextBrowser.append(_fromUtf8(item))