How to use get_disk_list method in autotest

Best Python code snippet using autotest_python

pve-info.py

Source:pve-info.py Github

copy

Full Screen

...142 disk_data['available'] = Utils.__get_unit(disk_info.free)143 disk_data['usage'] = '%.2f%s' % (disk_info.percent, '%')144 return disk_data145# get physics disk list and disk size146def get_disk_list():147 disk_name = []148 disk_size = []149 disk_info = dict()150 dev_list = os.popen(151 "lsblk -d -o NAME,SIZE,TYPE|grep disk|awk '{print $1,$2}'").read().strip().split('\n')152 # result like this153 # ['sda 40G', 'sdb 5G']154 for dev in dev_list:155 temp = dev.split(' ')156 disk_name.append('/dev/' + temp[0])157 disk_size.append(temp[1])158 # disk_name like ['/dev/sda', '/dev/sdb', '/dev/sdc']159 # 两个列表转为一个字典160 disk_info = dict(zip(disk_name, disk_size))161 return disk_name, disk_size, disk_info162# 显示系统硬盘大小163@timer.register(vpin_num=5, interval=update_int, run_once=False)164def write_to_virtual_pin(vpin_num=1):165 dev, size, info = get_disk_list()166 try:167 # re = format(168 # float(sub.check_output(["fdisk", "-s", dev[1]])) / 1024 / 1024,169 # '.2f')170 #value = format(float(re), ',')171 #print(WRITE_EVENT_PRINT_MSG.format('Disk1', value))172 print(WRITE_EVENT_PRINT_MSG.format('Disk1', info['/dev/sda']))173 #blynk.virtual_write(vpin_num, value)174 blynk.virtual_write(vpin_num, info['/dev/sda'])175 except Exception as g_err:176 print("Get sdb data error ".format(g_err))177# 显示500g硬盘大小178@timer.register(vpin_num=6, interval=update_int, run_once=False)179def write_to_virtual_pin(vpin_num=1):180 dev, size, info = get_disk_list()181 try:182 # re = format(183 # float(sub.check_output(["fdisk", "-s", dev[2]])) / 1024 / 1024,184 # '.2f')185 #value = format(float(re), ',')186 print(WRITE_EVENT_PRINT_MSG.format('Disk2', info['/dev/sdc']))187 blynk.virtual_write(vpin_num, info['/dev/sdc'])188 except Exception as g_err:189 print("Get sda data error ".format(g_err))190# 显示4t硬盘大小191@timer.register(vpin_num=14, interval=update_int, run_once=False)192def write_to_virtual_pin(vpin_num=1):193 dev, size, info = get_disk_list()194 try:195 # re = format(196 # float(sub.check_output(["fdisk", "-s", dev[0]])) / 1024 / 1024,197 # '.2f')198 #value = format(float(re), ',')199 print(WRITE_EVENT_PRINT_MSG.format('Disk2', info['/dev/sdb']))200 blynk.virtual_write(vpin_num, info['/dev/sdb'])201 except Exception as g_err:202 print("Get sda data error ".format(g_err))203# 显示硬盘使用率204@timer.register(vpin_num=7, interval=update_int, run_once=False)205def write_to_virtual_pin(vpin_num=1):206 dev, size, info = get_disk_list()207 # 读取系统硬盘使用率208 try:209 value = ps.disk_usage('/').percent210 print(WRITE_EVENT_PRINT_MSG.format('Disk1', value))211 blynk.virtual_write(vpin_num, value)212 except Exception as g_err:213 print("get disk data error ".format(g_err))214@timer.register(vpin_num=8, interval=update_int, run_once=False)215def write_to_virtual_pin(vpin_num=1):216 dev, size, info = get_disk_list()217 # 读取500g硬盘使用率218 try:219 value = ps.disk_usage(ps.disk_partitions()[2].mountpoint).percent220 print(WRITE_EVENT_PRINT_MSG.format('Disk2', value))221 blynk.virtual_write(vpin_num, value)222 except Exception as g_err:223 print("get data error ".format(g_err))224@timer.register(vpin_num=17, interval=update_int, run_once=False)225def write_to_virtual_pin(vpin_num=1):226 dev, size, info = get_disk_list()227 # 读取4t硬盘使用率228 try:229 value = ps.disk_usage(ps.disk_partitions()[4].mountpoint).percent230 print(WRITE_EVENT_PRINT_MSG.format('Disk3', value))231 blynk.virtual_write(vpin_num, value)232 except Exception as g_err:233 print("get data error ".format(g_err))234# 显示温度235# ps.sensors_temperatures()输出结果236# {'acpitz': [shwtemp(label='', current=27.8, high=105.0, critical=105.0), shwtemp(label='', current=29.8, high=105.0, critical=105.0)], 'coretemp': [shwtemp(label='Package id 0', current=49.0, high=100.0, critical=100.0), shwtemp(label='Core 0', current=49.0, high=100.0, critical=100.0), shwtemp(label='Core 1', current=45.0, high=100.0, critical=100.0), shwtemp(label='Package id 0', current=49.0, high=100.0, critical=100.0), shwtemp(label='Core 0', current=49.0, high=100.0, critical=100.0), shwtemp(label='Core 1', current=45.0, high=100.0, critical=100.0)]}237# cpu 1温度238@timer.register(vpin_num=9, interval=update_int, run_once=False)239def write_to_virtual_pin(vpin_num=1):240 try:241 value = ps.sensors_temperatures().get('coretemp')[1].current242 print(WRITE_EVENT_PRINT_MSG.format('tCPU1', value))243 blynk.virtual_write(vpin_num, value)244 except Exception as g_err:245 print("Get cpu1 temp error ".format(g_err))246# cpu 2247@timer.register(vpin_num=10, interval=update_int, run_once=False)248def write_to_virtual_pin(vpin_num=1):249 try:250 value = ps.sensors_temperatures().get('coretemp')[2].current251 print(WRITE_EVENT_PRINT_MSG.format('tCPU2', value))252 blynk.virtual_write(vpin_num, value)253 except Exception as g_err:254 print("Get cpu2 temp error ".format(g_err))255# 主板温度256# @timer.register(vpin_num=11, interval=update_int, run_once=False)257# def write_to_virtual_pin(vpin_num=1):258# try:259# value = ps.sensors_temperatures().items()[0][1][1].current260# print(WRITE_EVENT_PRINT_MSG.format('tBoard', value))261# blynk.virtual_write(vpin_num, value)262# except Exception as g_err:263# print("Get board temp error ".format(g_err))264# 系统硬盘温度265@timer.register(vpin_num=12, interval=update_int, run_once=False)266def write_to_virtual_pin(vpin_num=1):267 # result '/dev/sdb: Kston 64GB: 36\xc2\xb0C\n'268 dev, size, info = get_disk_list()269 try:270 re = sub.check_output(['hddtemp', dev[1]])271 value = int(re[-7:-4].strip()) # 去除空格272 print(WRITE_EVENT_PRINT_MSG.format('tHDD1', value))273 blynk.virtual_write(vpin_num, value)274 except Exception as g_err:275 print("Get disk temp error ".format(g_err))276# 500g硬盘温度277@timer.register(vpin_num=18, interval=update_int, run_once=False)278def write_to_virtual_pin(vpin_num=1):279 # result '/dev/sdb: Kston 64GB: 36\xc2\xb0C\n'280 dev, size, info = get_disk_list()281 try:282 re = sub.check_output(['hddtemp', dev[2]])283 value = int(re[-7:-4].strip()) # 去除空格284 print(WRITE_EVENT_PRINT_MSG.format('tHDD1', value))285 blynk.virtual_write(vpin_num, value)286 except Exception as g_err:287 print("Get disk temp error ".format(g_err))288# 显示网路发送数据289@timer.register(vpin_num=15, interval=update_int, run_once=False)290def write_to_virtual_pin(vpin_num=1):291 # 获取网络发送流量292 try:293 # value1 = format(float(ps.net_io_counters()[0]) / 1024 / 1024 / 1024, '.3f') # TB294 value1 = ps.net_io_counters(pernic=True)['enp2s0'].bytes_sent...

Full Screen

Full Screen

sysinfo.py

Source:sysinfo.py Github

copy

Full Screen

...15 return mem.used / mem.total * 10016def _get_mem_used() -> SizeGBType:17 mem = psutil.virtual_memory()18 return mem.used / 1024 ** 319def get_disk_list() -> typing.List:20 return [21 disk22 for disk in psutil.disk_partitions(all=False)23 if "loop" not in disk.device and not disk.mountpoint.startswith("/boot")24 ]25def _get_disk_paths() -> typing.List[str]:26 disks = get_disk_list()27 paths = [disk.mountpoint for disk in disks]28 return paths29def _get_disk_usage(path: str) -> Percentage100Type:30 return psutil.disk_usage(path).percent31def _get_disk_free_gb(path: str) -> SizeGBType:32 return psutil.disk_usage(path).free / 1024 ** 333# ---------------------------------------------------------------------------34def get_cpu_info() -> str:35 meminfo = psutil.virtual_memory()36 GB_div = 1024 ** 3 # pylint: disable=invalid-name37 info = (38 "```\n"39 + "\n".join(40 [41 f"Uptime: {timedelta(seconds=int(time.time() - psutil.boot_time()))}",42 f"CPUs: {psutil.cpu_count()}",43 f"RAM: {meminfo.total / GB_div:.1f} GB",44 "",45 "Load: 1min: {0[0]:.1f}%, 5min: {0[1]:.1f}%, 15min: {0[2]:.1f}%".format(46 _get_loadavg()47 ),48 f"Memory: {(meminfo.used / meminfo.total) * 100:.1f}% [used: {meminfo.used / GB_div:.1f} / {meminfo.total / GB_div:.1f} GB] [available: {meminfo.available / GB_div:.1f} GB]",49 ]50 )51 + "\n```"52 )53 return info54def get_disk_info() -> str:55 disks = get_disk_list()56 headers = ("Device", "Mount", "Use", "Total", "Used", "Free")57 rows = list()58 for disk in disks:59 usage = psutil.disk_usage(disk.mountpoint)60 rows.append(61 (62 disk.device,63 disk.mountpoint,64 f"{usage.percent:.1f} %",65 bytes2human(usage.total),66 bytes2human(usage.used),67 bytes2human(usage.free),68 # disk.fstype,69 )...

Full Screen

Full Screen

get_path.py

Source:get_path.py Github

copy

Full Screen

...27 if dir_name == key:28 git_path = os.path.realpath(super_dir)29 return git_path30 return None31def get_disk_list():32 """get windows disk names"""33 disk_list = []34 for c in string.ascii_uppercase:35 disk_name = c + ':\\'36 if os.path.isdir(disk_name):37 disk_list.append(disk_name)38 return disk_list39def get_paths():40 disks = get_disk_list()41 for disk in disks:42 cmd_path, bin_path = find_bash(target_path=disk)43 if cmd_path and bin_path:44 pass45 return cmd_path, bin_path46 return None, None...

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 autotest 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