def run(self): while True: data = self.game.recv(4096) if data: #print "[{}] -> {}".format(self.port, data[:100].encode('hex')) try: mparser.parse(data, self.port, 'client') if len(mparser.SERVER_QUEUE) > 0: pkt = mparser.SERVER_QUEUE.pop() #print "got queue server: {}".format(pkt.encode('hex')) self.server.sendall(pkt) except Exception as e: print('client[{}]'.format(self.port), e) # forward to server self.server.sendall(data)
def run(self): while True: data = self.server.recv(4096) if data: #print "[{}] <- {}".format(self.port, data[:100].encode('hex')) try: mparser.parse(data, self.port, 'server') if len(mparser.CLIENT_QUEUE) > 0: pkt = mparser.CLIENT_QUEUE.pop() #print "got queue client: {}".format(pkt.encode('hex')) self.game.sendall(pkt) except Exception as e: print('server[{}]'.format(self.port), e) # forward to client self.game.sendall(data)
def run(self): while True: data, addr = self.sock.recvfrom(8192) self.game.sAddr = self.address if data: #print ("[{}] <- {}".format(self.port, data[:100].hex())) try: mparser.parse(data, self.port, 'server') if len(mparser.CLIENT_QUEUE) > 0: pkt = mparser.CLIENT_QUEUE.pop() #print "got queue client: {}".format(pkt.encode('hex')) self.game.sock.sendto(pkt, self.game.address) except Exception as e: print('server[{}]'.format(self.port), e) # forward to client self.game.sock.sendto(data, self.game.address)
def run(self): while True: data, addr = self.sock.recvfrom(4096) if data: #print ("[{}] -> {}".format(self.port, data[:100].hex())) try: mparser.parse(data, self.port, 'client') if len(mparser.SERVER_QUEUE) > 0: pkt = mparser.SERVER_QUEUE.pop() #print "got queue server: {}".format(pkt.encode('hex')) self.server.sock.sendto(pkt, (self.host, self.port)) except Exception as e: print('client[{}]'.format(self.port), e) # forward to server self.server.sock.send(data)
def main(): #shutil.copyfile(r"ts.xlsx", r"ts1.xlsx") s = input('Имя файла: ') time.sleep(1) #Кароч метод LoadFile не хочет возвращать wb, вывод питон - х##ня name = 'Files/Strelova_Ekaterina_Vasilyevna' wb = load_workbook(name + ".xlsx", data_only=True) sheet = wb.active p = person.MakePersonList(sheet) for perid in range(len(p)): print(perid) persons = [] info = p[perid]['info'] p[perid] = mparser.parse(info, p[perid]) params = {'Фамилия': p[perid]['surname'], 'Имя': p[perid]['name'], 'Отчество': p[perid]['faname'], 'Звание': p[perid]['rank'], 'Дата рождения/Возраст': p[perid]['birthyear'], 'Дата выбытия': p[perid]['deathday'], 'Причина выбытия': p[perid]['reason']} persons = web.getRecords(1, params, []) max = 0 maxpersons = [] print(persons) if (persons != []): print('======================================') for i in range(len(persons)): if (persons[i]['percent'] > max): max = persons[i]['percent'] for i in range(len(persons)): if (persons[i]['percent'] == max): maxpersons.append(persons[i]) if (maxpersons != []): max = 0 maxindex = -1 print(len(maxpersons)) for i in range(0, len(maxpersons)): print(len(str(maxpersons[i])) > max) if len(str(maxpersons[i])) > max: max = len(str(maxpersons[i])) maxindex = i print('!!!', maxpersons[maxindex], '!!!') print('***************************************') p[perid]['link'] = "https://obd-memorial.ru/html/info.htm?id=" + maxpersons[maxindex]['id'] size = person.GetSize(sheet) for i in range(2, size + 1): j = 6 while (j < 22): if (p[i-2][person.field_name[j-1]] != None): sheet[get_column_letter(j) + str(i)].value = p[i-2][person.field_name[j-1]] else: sheet[get_column_letter(j) + str(i)].value = "" j += 1 wb.save(name + "final.xlsx")