def EmptyCacheIgnoreBroadcastIncant(socket, lvl): resp = [] incant = False while (len(resp) == 0): resp = socket.ReadSocket() check_dead(resp) i = 0 while i < len(resp): if resp[i].find("message") != -1: resp.pop(i) elif resp[i].find("Elevation underway") != -1: incant = True print("INCANT TRUE : " + str(resp[i])) print("CURRENT LIST : " + str(resp)) resp.pop(i) elif resp[i].find("Current level:") != -1: print("FOUND CURRENT LEVEL") ret = re.findall('\d+', resp[i]) if len(ret) > 0: if int(ret[0]) != lvl: return resp, int(ret[0]) else: i += 1 if incant is True: for response in resp: if "Current level:" in response: ret = re.findall('\d+', response) if len(ret) > 0: if int(ret[0]) != lvl: return resp, int(ret[0]) print("IngnoreBroadcastIncant resp = " + str(resp)) return resp, lvl
def EmptyCache(self): resp = [] while (len(resp) == 0): resp = self.ReadSocket() check_dead(resp) print("resp = " + str(resp)) return (resp)
def EmptyCacheFocusBroadcast(socket, lvl): mess = [] dire = -1 message = [] direction = -1 incant = False resp = [] while (len(resp) == 0): resp = socket.ReadSocket() check_dead(resp) i = 0 while i < len(resp): if resp[i].find("message") != -1: direction, message = parse_message(socket, resp[i]) print("ID DIFFERENCE " + str(socket.target_id) + " ?= " + str(message[0])) if (len(message) >= 3 and message[1] == "INCANT" and int(message[2]) == lvl and socket.target_id == message[0]): dire = direction mess = message keep = 1 resp.pop(i) elif resp[i].find("Elevation underway") != -1: incant = True resp.pop(i) elif resp[i].find("Current level:") != -1: print("FOUND CURRENT LEVEL") ret = re.findall('\d+', resp[i]) if len(ret) > 0: if int(ret[0]) != lvl: return dire, mess, resp, int(ret[0]) else: i += 1 if incant is True: ret_incant, level = EmptyCacheIgnoreBroadcast(socket, lvl) if (level != lvl): return dire, mess, resp, level for response in ret_incant: if "Current level:" in response: ret = re.findall('\d+', response) if len(ret) > 0: if int(ret[0]) != lvl: return dire, mess, resp, int(ret[0]) return dire, mess, resp, lvl print("FOCUSBROADCAST resp = " + str(resp) + " mess = " + str(mess) + " dire = " + str(dire)) return dire, mess, resp, lvl