How to use format_disk method in lisa

Best Python code snippet using lisa_python

diskhandler.py

Source:diskhandler.py Github

copy

Full Screen

1#!/usr/bin/python2import argparse3import os4import sys5myfolder = os.path.dirname(os.path.abspath(__file__))6lib_path = os.path.join(myfolder, "../lib/")7sys.path.append(lib_path)8import format_disk9import mount_connected_disks10import storage_structure_handler11import subprocess12import time13import threading14import prepare_and_format_blockdevice15import BlockDeviceHandler16def rpienv_source():17 if not os.path.exists(str(myfolder) + '/.rpienv'):18 print("[ ENV ERROR ] " + str(myfolder) + "/.rpienv path not exits!")19 sys.exit(1)20 command = ['bash', '-c', 'source ' + str(myfolder) + '/.rpienv -s && env']21 proc = subprocess.Popen(command, stdout = subprocess.PIPE)22 for line in proc.stdout:23 if type(line) is bytes:24 line = line.decode("utf-8")25 try:26 name = line.partition("=")[0]27 value = line.partition("=")[2]28 if type(value) is unicode:29 value = value.encode('ascii','ignore')30 value = value.rstrip()31 os.environ[name] = value32 except Exception as e:33 if "name 'unicode' is not defined" != str(e):34 print(e)35 proc.communicate()36rpienv_source()37try:38 confhandler_path = os.path.join(os.path.dirname(os.environ['CONFIGHANDLERPY']))39 sys.path.append(confhandler_path)40 import ConfigHandler41 cfg = ConfigHandler.init()42except Exception as e:43 print("Import config handler failed: " + str(e))44parser = argparse.ArgumentParser()45parser.add_argument("-s", "--search_get_edit", action='store_true', help="Search devices (/dev/sda*), get label and uuid, set fstab file")46parser.add_argument("-m", "--mount", action='store_true', help="Mount avaible devices (/media/*)")47parser.add_argument("-f", "--format_ext4", action='store_true', help="Format device for ext4 filesystem")48parser.add_argument("-l", "--listdevs", action='store_true', help="List connected devices with seversal commands")49parser.add_argument("-t", "--storage_structure", action='store_true', help="Set storage folder structure")50parser.add_argument("-w", "--show_storage_structure", action='store_true', help="Show storage folder structure")51parser.add_argument("-p", "--prepare_disks", action='store_true', help="Prepare disks whick contains diskconf.json")52parser.add_argument("-c", "--change_dev_name", action='store_true', help="Change disk label name")53args = parser.parse_args()54sge = args.search_get_edit55mount = args.mount56form = args.format_ext457listdev = args.listdevs58storage = args.storage_structure59show_storage_structure = args.show_storage_structure60prepare_disks = args.prepare_disks61change_dev_name =args.change_dev_name62def pre_check(info="CKECK"):63 state, msg = BlockDeviceHandler.is_any_device_avaible()64 if not state:65 print("{} There are no connected devices: {}".format(info, msg))66 sys.exit(444)67def main():68 if sge:69 pre_check("do_search_get_edit")70 mount_connected_disks.do_search_get_edit()71 if mount:72 pre_check("mount")73 mount_connected_disks.mount()74 if form:75 pre_check("format_disk")76 format_disk.main()77 if listdev:78 pre_check("hum_readable_list_devices")79 format_disk.hum_readable_list_devices()80 if storage:81 if str(cfg.get(section="STORAGE", option="external")).lower() == "true":82 set_extarnal_storage = True83 else:84 set_extarnal_storage = False85 external_storage_label = str(cfg.get(section="STORAGE", option="label")).rstrip()86 storage_structure_handler.create_storage_stucrure(set_extarnal_storage, external_storage_label)87 if show_storage_structure:88 if str(cfg.get(section="STORAGE", option="external")).lower() == "true":89 set_extarnal_storage = True90 else:91 set_extarnal_storage = False92 external_storage_label = str(cfg.get(section="STORAGE", option="label")).rstrip()93 text = storage_structure_handler.get_storage_structure_folders(set_extarnal_storage, external_storage_label)94 if prepare_disks:95 pre_check("prepare_block_device")96 if str(cfg.get(section="STORAGE", option="external")).lower() == "true":97 prepare_and_format_blockdevice.prepare_block_device()98 else:99 print("For automatic disk format based on diskconf.json switch STORAGE -> external True in rpitools_config.conf")100 if change_dev_name:101 pre_check("change_dev_name")102 format_disk.hum_readable_list_devices()103 device = raw_input("Select device path:\t/dev/sdaX: ")104 name = raw_input("New disk label name: ")105 mount_connected_disks.set_get_device_name(device, name)106if __name__ == "__main__":107 main()108 time.sleep(1)...

Full Screen

Full Screen

disks.py

Source:disks.py Github

copy

Full Screen

...44def umount_disk(name: str):45 sudo_password = config.SUDO_PASSWORD46 command_umount = f'umount /dev/{name}'47 os.system(f'echo {sudo_password}|sudo -S {command_umount}')48def format_disk(name: str):49 sudo_password = config.SUDO_PASSWORD50 command_format = f'mkfs /dev/{name}'51 if os.system(f'echo {sudo_password}|sudo -S {command_format}') == 0:52 return True53 else:54 if os.system(f'echo {sudo_password}|sudo -S {command_format}|y') == 0:55 return True56 else:57 return False58if __name__ == "__main__":59 print(format_disk('sda'))...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1import time as t2from CDM.code import cdm_run3from clean_disk import format_disk4from H2.code import h2_run5from ATTO.code import atto_run6from AS_SSD.code import as_ssd_run7from PCMark.code import pcmark_run8from HDTune.code import hd_run9from IOmeter.code import iometer_run10tool_path = '' # 配置工具文件目录11start = t.time()12# # 运行HDTune测试13# hd_run.main()14# print('HDTune测试完成!')15# t.sleep(5)16# format_disk.main()17# # 运行CDM所有版本18# cdm_run.cdm()19# print('CDM测试完成!')20# t.sleep(1)21# format_disk.main()22# t.sleep(1)23# # 运行h2testw1.424# h2_run.main()25# print('H2测试完成!')26# t.sleep(1)27# format_disk.main()28# t.sleep(1)29# # 运行ATTO测试30# atto_run.main()31# print('ATTO测试完成')32# t.sleep(1)33# format_disk.main()34# t.sleep(1)35# # 运行PCMark测试36# pcmark_run.main()37# print('PCMark测试完成!')38# t.sleep(1)39# format_disk.main()40# t.sleep(1)41# # 运行IOMeter测试42# iometer_run.iometer_0()43# t.sleep(1)44# iometer_run.iometer_10G()45# print('IOMeter测试完成!')46# t.sleep(1)47# format_disk.main()48# t.sleep(1)49elapsed = (t.time() - start)...

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