mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-23 05:35:44 -05:00
image/fastboot: use exec.cmd.run_cmd() for loggability
This commit is contained in:
parent
604f123067
commit
8a266f9149
1 changed files with 6 additions and 4 deletions
|
@ -1,12 +1,12 @@
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
from exec.cmd import run_cmd, CompletedProcess
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
def fastboot_erase_dtbo():
|
def fastboot_erase_dtbo():
|
||||||
logging.info("Fastboot: Erasing DTBO")
|
logging.info("Fastboot: Erasing DTBO")
|
||||||
subprocess.run(
|
run_cmd(
|
||||||
[
|
[
|
||||||
'fastboot',
|
'fastboot',
|
||||||
'erase',
|
'erase',
|
||||||
|
@ -18,23 +18,25 @@ def fastboot_erase_dtbo():
|
||||||
|
|
||||||
def fastboot_flash(partition: str, file: str, sparse_size: Optional[str] = None):
|
def fastboot_flash(partition: str, file: str, sparse_size: Optional[str] = None):
|
||||||
logging.info(f"Fastboot: Flashing {file} to {partition}")
|
logging.info(f"Fastboot: Flashing {file} to {partition}")
|
||||||
result = subprocess.run([
|
result = run_cmd([
|
||||||
'fastboot',
|
'fastboot',
|
||||||
*(['-S', sparse_size] if sparse_size is not None else []),
|
*(['-S', sparse_size] if sparse_size is not None else []),
|
||||||
'flash',
|
'flash',
|
||||||
partition,
|
partition,
|
||||||
file,
|
file,
|
||||||
])
|
])
|
||||||
|
assert isinstance(result, CompletedProcess)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise Exception(f'Failed to flash {file}')
|
raise Exception(f'Failed to flash {file}')
|
||||||
|
|
||||||
|
|
||||||
def fastboot_boot(file):
|
def fastboot_boot(file):
|
||||||
logging.info(f"Fastboot: booting {file}")
|
logging.info(f"Fastboot: booting {file}")
|
||||||
result = subprocess.run([
|
result = run_cmd([
|
||||||
'fastboot',
|
'fastboot',
|
||||||
'boot',
|
'boot',
|
||||||
file,
|
file,
|
||||||
])
|
])
|
||||||
|
assert isinstance(result, CompletedProcess)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise Exception(f'Failed to boot {file} using fastboot')
|
raise Exception(f'Failed to boot {file} using fastboot')
|
||||||
|
|
Loading…
Add table
Reference in a new issue