How to use get_partition_info method in lisa

Best Python code snippet using lisa_python

parttool.py

Source:parttool.py Github

copy

Full Screen

...92 esptool_args += ["--baud", str(self.baud)]93 esptool_args += args94 with open(os.devnull, "w") as null_file:95 subprocess.check_call(esptool_args, stdout=null_file, stderr=null_file)96 def get_partition_info(self, partition_id):97 partition = None98 if partition_id.name:99 partition = self.partition_table.find_by_name(partition_id.name)100 elif partition_id.type and partition_id.subtype:101 partition = self.partition_table.find_by_type(partition_id.type, partition_id.subtype)102 else: # default boot partition103 search = ["factory"] + ["ota_{}".format(d) for d in range(16)]104 for subtype in search:105 partition = self.partition_table.find_by_type("app", subtype)106 if partition:107 break108 if not partition:109 raise Exception("Partition does not exist")110 return partition111 def erase_partition(self, partition_id):112 partition = self.get_partition_info(partition_id)113 self._call_esptool(["erase_region", str(partition.offset), str(partition.size)] + self.esptool_erase_args)114 def read_partition(self, partition_id, output):115 partition = self.get_partition_info(partition_id)116 self._call_esptool(["read_flash", str(partition.offset), str(partition.size), output] + self.esptool_read_args)117 def write_partition(self, partition_id, input):118 self.erase_partition(partition_id)119 partition = self.get_partition_info(partition_id)120 with open(input, "rb") as input_file:121 content_len = len(input_file.read())122 if content_len > partition.size:123 raise Exception("Input file size exceeds partition size")124 self._call_esptool(["write_flash", str(partition.offset), input] + self.esptool_write_args)125def _write_partition(target, partition_id, input):126 target.write_partition(partition_id, input)127 partition = target.get_partition_info(partition_id)128 status("Written contents of file '{}' at offset 0x{:x}".format(input, partition.offset))129def _read_partition(target, partition_id, output):130 target.read_partition(partition_id, output)131 partition = target.get_partition_info(partition_id)132 status("Read partition '{}' contents from device at offset 0x{:x} to file '{}'"133 .format(partition.name, partition.offset, output))134def _erase_partition(target, partition_id):135 target.erase_partition(partition_id)136 partition = target.get_partition_info(partition_id)137 status("Erased partition '{}' at offset 0x{:x}".format(partition.name, partition.offset))138def _get_partition_info(target, partition_id, info):139 try:140 partition = target.get_partition_info(partition_id)141 except Exception:142 return143 info_dict = {144 "offset": '0x{:x}'.format(partition.offset),145 "size": '0x{:x}'.format(partition.size)146 }147 infos = []148 try:149 for i in info:150 infos += [info_dict[i]]151 except KeyError:152 raise RuntimeError("Request for unknown partition info {}".format(i))153 print(" ".join(infos))154def main():...

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