def get_ip(xmlfile,repeat=True): try: xml=parse_xml(xmlfile,show_log=False) #判断文件 xml.xml_exists() name=xmlfile.split(".")[0] namefile="%s_ip.txt"%name if os.path.exists(namefile): os.remove(namefile) file=open(namefile,'w+') xml.get_root() childs=xml.get_element_children(xml.root) if repeat: ips=[] print "####################################### %s 渠道 IP 列表(去重) 如下: (以保存%s中) #######################################"%(name,namefile) for child in childs: ips.append(child.get("ip")) ips=sorted(list(set(ips))) for ip in ips: print ip file.write(ip) file.write("\n") else: print "####################################### %s 渠道 IP 列表如下: (以保存%s中) #######################################"%(name,namefile) for child in childs: print child.get("ip") file.write(child.get("ip")) file.write("\n") except Exception as err: print err finally: file.close()
def get_info(xmlfile): try: xml=parse_xml(xmlfile,show_log=False) #判断文件 xml.xml_exists() xml.get_root() all={} childs=xml.get_element_children(xml.root) for child in childs: cid=child.get("id") ip=child.get("ip") plat=child.get("platform") dirc={cid:{}} dirc[cid].update({"ip":ip,"palt":plat}) all.update(dirc) return all except Exception as err: print err
def get_info(xmlfile): try: xml = parse_xml(xmlfile, show_log=False) #判断文件 xml.xml_exists() xml.get_root() all = {} childs = xml.get_element_children(xml.root) for child in childs: cid = child.get("id") ip = child.get("ip") plat = child.get("platform") dirc = {cid: {}} dirc[cid].update({"ip": ip, "palt": plat}) all.update(dirc) return all except Exception as err: print err
def get_info(xmlfile): try: xml=parse_xml(xmlfile,show_log=False) #判断文件 xml.xml_exists() xml.get_root() all={} #dirc={} childs=xml.get_element_children(xml.root) for child in childs: plat=child.get("platform") cid=child.get("id") ip=child.get("ip") mark=plat+"_s"+cid dirc={mark:{}} dirc[mark].update({"ip":ip,"id":cid,"platform":plat}) all.update(dirc) return all except Exception as err: print "获取失败.错误如下:",err
def get_info(xmlfile): try: xml = parse_xml(xmlfile, show_log=False) #判断文件 xml.xml_exists() xml.get_root() all = {} #dirc={} childs = xml.get_element_children(xml.root) for child in childs: plat = child.get("platform") cid = child.get("id") ip = child.get("ip") mark = plat + "_s" + cid dirc = {mark: {}} dirc[mark].update({"ip": ip, "id": cid, "platform": plat}) all.update(dirc) return all except Exception as err: print "获取失败.错误如下:", err
def get_all_info(xmlfile,ret=True): try: xml=parse_xml(xmlfile,show_log=False) #判断文件 xml.xml_exists() xml.get_root() all=[] childs=xml.get_element_children(xml.root) name=xmlfile.split(".")[0] namefile="%s_info.txt"%name if os.path.exists(namefile): os.remove(namefile) file=open(namefile,'w+') for child in childs: l=[] cid=child.get("id") ip=child.get("ip") plat=child.get("platform") l.append(cid) l.append(ip) l.append(plat) all.append(l) file.write(cid) file.write(" ") file.write(ip) file.write(" ") file.write(plat) file.write("\n") file.close() if ret: print "####服#### ##### ip #### #### 平台 ####" for s in all: print " %s %s %s"%(s[0],s[1],s[2]) return all except Exception as err: print err
def get_all_info(xmlfile, ret=True): try: xml = parse_xml(xmlfile, show_log=False) #判断文件 xml.xml_exists() xml.get_root() all = [] childs = xml.get_element_children(xml.root) name = xmlfile.split(".")[0] namefile = "%s_info.txt" % name if os.path.exists(namefile): os.remove(namefile) file = open(namefile, 'w+') for child in childs: l = [] cid = child.get("id") ip = child.get("ip") plat = child.get("platform") l.append(cid) l.append(ip) l.append(plat) all.append(l) file.write(cid) file.write(" ") file.write(ip) file.write(" ") file.write(plat) file.write("\n") file.close() if ret: print "####服#### ##### ip #### #### 平台 ####" for s in all: print " %s %s %s" % (s[0], s[1], s[2]) return all except Exception as err: print err
def get_ip(xmlfile, repeat=True): try: xml = parse_xml(xmlfile, show_log=False) #判断文件 xml.xml_exists() name = xmlfile.split(".")[0] namefile = "%s_ip.txt" % name if os.path.exists(namefile): os.remove(namefile) file = open(namefile, 'w+') xml.get_root() childs = xml.get_element_children(xml.root) if repeat: ips = [] print "####################################### %s 渠道 IP 列表(去重) 如下: (以保存%s中) #######################################" % ( name, namefile) for child in childs: ips.append(child.get("ip")) ips = sorted(list(set(ips))) for ip in ips: print ip file.write(ip) file.write("\n") else: print "####################################### %s 渠道 IP 列表如下: (以保存%s中) #######################################" % ( name, namefile) for child in childs: print child.get("ip") file.write(child.get("ip")) file.write("\n") except Exception as err: print err finally: file.close()
if share_memory[INDEX_CLAW_CLOSE_FLAG] == SET: robot_handle.close_claw() share_memory[INDEX_CLAW_CLOSE_FLAG] = CLEAR if __name__ == '__main__': manager = Manager() share_memory = manager.list() for i in range(25): share_memory.append(CLEAR) share_memory.append(recv_data) share_memory.append(send_data) share_memory.append(joint_data) share_memory.append(pos_data) share_memory.append(line_state) process_robot = Process(target=robot_process, args=(share_memory, )) process_robot.start() process_protocol = Process(target=protocol_process, args=(share_memory, )) process_protocol.start() multi_process = parse_xml("process.xml") multi_process_handle = MultiProcessHandle(multi_process, share_memory) while True: pass