How to use is_bond method in avocado

Best Python code snippet using avocado_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...103 @property104 def is_available(self):105 return PortManager().is_available(self)106 @property107 def is_bond(self):108 return 'eth_bond' in self.name109 @property110 def is_dpdk(self):111 return self.driver == self.dpdk_driver or \112 self.is_bond or self.is_ring113 @property114 def is_netmap(self):115 return self.driver == self.netmap_driver116 @property117 def is_ring(self):118 return 'eth_ring' in self.name119 @property120 def is_virtual(self):121 return self.is_bond or self.is_ring...

Full Screen

Full Screen

models.py

Source:models.py Github

copy

Full Screen

1# -*- coding:utf-8 -*-2import logging3import traceback4from django.conf import settings5from utils.utils import is_private_ip, mask_repr6# 内存信息7class MemInfo(object):8 def __init__(self):9 # 5.1 生产厂商10 self.mem_mf = ''11 # 5.2 型号12 self.mem_model = ''13 # 5.3 容量 (GB)14 self.mem_size = 015 # 5.4 数量16 self.mem_number = 017 18class HardDiskInfo(object):19 def __init__(self):20 # 6.1 编号21 self.hd_sn = ''22 # 6.2 生产厂商23 self.hd_mf = ''24 # 6.3 接口类型25 self.hd_interface = ''26 # 6.4 型号27 self.hd_model = ''28 # 6.5 转速29 self.hd_speed = 030 # 6.6 单盘容量(G)31 self.hd_size = 032 # 6.7 数量33 self.hd_number = 034# 主机硬件信息35class HostHardware(object):36 def __init__(self):37 # 1. 机器信息38 # 1.1 机器生产厂商39 self.machine_mf = ''40 # 1.2 机器型号41 self.machine_model = ''42 # 1.3 机器序列号43 self.machine_sn = ''44 45 # 2. 操作系统46 # 2.1 OS类型47 self.os_type = ''48 # 2.2 OS位数49 self.os_bit = ''50 # 2.3 OS版本51 self.os_version = ''52 53 # 3. IP信息54 # 3.1 管理IP 55 self.manage_ip = ''56 # 3.2 内网IP (有多个则逗号分隔)57 self.private_ip = ''58 # 3.3 外网IP (有多个则逗号分隔)59 self.public_ip = ''60 # 3.4 是否Bond61 self.is_bond = False62 # 3.5 域名服务器63 self.nameserver = ''64 65 # 4. CPU信息66 # 4.1 CPU生产厂商67 self.processor_mf = ''68 # 4.2 型号69 self.processor_model = ''70 # 4.3 内核数71 self.processor_cores = 072 # 4.4 数量(个数)73 self.processor_number = 074 75 # 5. 内存信息76 self.mem_list = []77 78 # 6. 磁盘信息79 self.hard_disk_list = []80def parse_ip_info(data):81 private_ip_list = []82 public_ip_list = []83 item_list = data.split(';')84 for item in item_list:85 temp_list = item.split(':')86 tt = '%s/%s %s' % (temp_list[1], mask_repr(temp_list[2]), temp_list[3])87 88 if is_private_ip(temp_list[1]):89 private_ip_list.append(tt)90 else:91 public_ip_list.append(tt)92 93 data = data.lower() 94 95 is_bond = True96 if data.find('bond') == -1:97 is_bond = False98 99 return ','.join(private_ip_list), ','.join(public_ip_list), is_bond100 101 102def parse_mem_info(data):103 res_list = []104 item_list = data.split(';')105 for item in item_list:106 temp_list = item.split(':')107 m = MemInfo()108 m.mem_mf = temp_list[0]109 m.mem_model = temp_list[1]110 m.mem_size = temp_list[2]111 m.mem_number = temp_list[3]112 res_list.append(m)113 return res_list114 115# 到处所有机器的硬件信息列表 116def export_hardware_info():117 logger = logging.getLogger("django")118 pipe = settings.REDIS_DB.pipeline()119 120 # 通过硬件检查结果得到121 ip_host_dict = settings.REDIS_DB.hgetall("ip_host")122 123 host_set = set()124 logger.info("获取ip_host列表")125 for ip in ip_host_dict:126 logger.info("IP:%s, host_id:%s", ip, ip_host_dict[ip])127 host = ip_host_dict[ip]128 # 只提取真实主机的信息129 if host.startswith('GD'):130 host_set.add(host)131 132 host_list = list(host_set) 133 for host in host_list:134 pipe.hgetall(host + '_hc') 135 136 item_list = pipe.execute()137 res_list = []138 # 失败数139 fail_count = 0140 count = len(item_list)141 for i in range(len(item_list)):142 host = host_list[i]143 logger.info("开始处理主机硬件信息, host_id:%s", host)144 145 item = item_list[i]146 if not item:147 continue148 try: 149 temp = HostHardware()150 temp.machine_mf = item['MANUFACTURER'] 151 temp.machine_model = item['PRODUCT_NAME']152 temp.machine_sn = item['SERIAL_NUMBER']153 154 temp.os_type = item['OS_TYPE']155 temp.os_bit = item['OS_BIT']156 temp.os_version = item['OS_VERSION']157 158 temp.manage_ip = item['MANAGE_IP']159 #temp.manage_ip = ''160 temp.private_ip, temp.public_ip, temp.is_bond = parse_ip_info(item['SYS_NETWORK'])161 162 #temp.private_ip = item['IP']163 164 temp.nameserver = item['NAMESERVER']165 166 temp.processor_mf = item['PROCESSOR_MANUFACTURER']167 temp.processor_model = item['PROCESSOR_TYPE']168 temp.processor_cores = item['PROCESSOR_CORES']169 temp.processor_number = item['PROCESSOR_NUMBER']170 171 temp.mem_list = parse_mem_info(item['MEM_INFO'])172 173 # 目前没有取得硬盘信息, 插入一条空记录174 hd = HardDiskInfo()175 hd.hd_sn = ''176 hd.hd_mf = ''177 hd.hd_interface = ''178 hd.hd_model = ''179 hd.hd_speed = ''180 hd.hd_size = ''181 hd.hd_number = ''182 183 temp.hard_disk_list = [hd]184 185 res_list.append(temp)186 except BaseException:187 fail_count = fail_count + 1188 logger.error("处理主机硬件信息异常,host_id:%s, 附加信息:\n%s", host, traceback.format_exc())189 190 logger.error("共处理主机数:%s, 失败数:%s", count, fail_count)191 return res_list192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 ...

Full Screen

Full Screen

connectivity.py

Source:connectivity.py Github

copy

Full Screen

1import numpy as np2from math import *3from .util import *4from .molecule import *5import sys6write = sys.stdout.write7def print_distance_and_connectivity(distances, connectivity, molecule):8 write("Covalent bonds in the molecule:\n")9 natoms = molecule.natoms10 for k in range(0, natoms):11 for l in range(k+1, natoms):12 if connectivity[k+l*natoms] == 1:13 write(" %2s%-3d - %2s%-3d: %9.5f Ang\n" % 14 (molecule.atmsym[k], k+1, molecule.atmsym[l], l+1, distances[k+l*natoms]))15 write("\n")16def print_distances_2_img(xyzfile, distances, connectivity, molecule):17 spt = open("connect.spt", "w")18 spt.write("background = white\n")19 spt.write("load "+xyzfile+"\n")20 spt.write("label %a\n")21 spt.write("defaultDistanceLabel = \"%6.4VALUE\"\n")22 spt.write("set measurements angstroms\n")23 spt.write("set measurementnumbers on\n")24 natoms = molecule.natoms25 for k in range(0, natoms):26 for l in range(k+1, natoms):27 if connectivity[k+l*natoms] == 1 and molecule.atmsym[k] != 'H' and molecule.atmsym[l] != 'H':28 spt.write("measure (atomno=%3d) (atomno=%3d)\n" % (k+1, l+1))29 spt.write("write image "+xyzfile[:-3]+"png\n")30 spt.close()31 os.system("jmol -n connect.spt")32def get_distance_and_connectivity(distances, connectivity, molecule):33 natoms = molecule.natoms34 #write("natoms=%d\n" % (natoms))35 connect = []36 for k in range(0, natoms*natoms):37 connect.append(0)38 # nearest neighbors39 for i in range(0, natoms):40 for j in range(i+1, natoms):41 #compute distance42 r2 = 043 for k in range(0, 3):44 diff = molecule.coords[3*i+k] - molecule.coords[3*j+k]45 r2 += diff*diff46 dist = sqrt(r2)*BOHR47 distances[i+j*natoms] = distances[j+i*natoms] = dist48 #connectivitity49 #this is a little bit arbitrary, need to fix later50 is_bond = 051 if molecule.atmsym[i] != 'H' and molecule.atmsym[j] != 'H':52 is_bond = dist < 1.953 elif molecule.atmsym[i] != 'H' or molecule.atmsym[j] != 'H':54 if molecule.atmsym[i] == 'O' or molecule.atmsym[j] == 'O': #O-H bond55 is_bond = dist < 1.256 else:57 is_bond = dist < 1.658 else:59 is_bond = dist < 1.260 if is_bond: 61 connect[i+j*natoms] = connect[j+i*natoms] = 162 # second-nearest neighbors63 for i in range(0, natoms):64 for j in range(0, natoms):65 if connect[i+j*natoms] == 1:66 for k in range(0, natoms):67 if k != i and k != j and connect[k+j*natoms] == 1 and connect[k+i*natoms] == 0:68 connect[k+i*natoms] = connect[i+k*natoms] = 269 # third-nearest neighbors70 for i in range(0, natoms):71 for j in range(0, natoms):72 if connect[i+j*natoms] == 2:73 for k in range(0, natoms):74 if k != i and k != j and connect[k+j*natoms] == 1 and connect[k+i*natoms] == 0:75 connect[k+i*natoms] = connect[i+k*natoms] = 376 connectivity[:] = connect77def fragment_analysis(frag_index, natoms, connectivity):78 ifrag = -179 for m in range(0, natoms): frag_index.append(-1)80 for m in range(0, natoms): 81 iatom = -182 for n in range(0, natoms):83 if frag_index[n] == -1: 84 iatom = n 85 ifrag += 186 break87 #print("iatom: ", iatom, "ifrag=", ifrag)88 if iatom == -1: break89 frag_index[iatom] = ifrag90 for n in range(0, natoms):91 if frag_index[n] == -1:92 for k in range(0, natoms):93 if frag_index[k] == ifrag and connectivity[k+n*natoms] == 1:94 frag_index[n] = ifrag...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful