Added find_first_partition()
This commit is contained in:
parent
9652aa4623
commit
4215a2fd78
1 changed files with 17 additions and 13 deletions
|
|
@ -107,6 +107,22 @@ def update_boot_entries(boot_entries, boot_files, iso_label, ufd_label):
|
||||||
run_program(cmd)
|
run_program(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
def find_first_partition(dev_path):
|
||||||
|
"""Find path to first partition of dev, returns str."""
|
||||||
|
cmd = [
|
||||||
|
'lsblk',
|
||||||
|
'--list',
|
||||||
|
'--noheadings',
|
||||||
|
'--output', 'name',
|
||||||
|
'--paths',
|
||||||
|
dev_path,
|
||||||
|
]
|
||||||
|
result = run_program(cmd, encoding='utf-8', errors='ignore')
|
||||||
|
part_path = result.stdout.splitlines()[-1].strip()
|
||||||
|
|
||||||
|
return part_path
|
||||||
|
|
||||||
|
|
||||||
def find_path(path):
|
def find_path(path):
|
||||||
"""Find path case-insensitively, returns pathlib.Path obj."""
|
"""Find path case-insensitively, returns pathlib.Path obj."""
|
||||||
path_obj = pathlib.Path(path).resolve()
|
path_obj = pathlib.Path(path).resolve()
|
||||||
|
|
@ -235,23 +251,11 @@ def prep_device(dev_path, label, use_mbr=False):
|
||||||
cmd=cmd,
|
cmd=cmd,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Find partition
|
|
||||||
cmd = [
|
|
||||||
'lsblk',
|
|
||||||
'--list',
|
|
||||||
'--noheadings',
|
|
||||||
'--output', 'name',
|
|
||||||
'--paths',
|
|
||||||
dev_path,
|
|
||||||
]
|
|
||||||
result = run_program(cmd, encoding='utf-8', errors='ignore')
|
|
||||||
part_path = result.stdout.splitlines()[-1].strip()
|
|
||||||
|
|
||||||
# Format partition
|
# Format partition
|
||||||
cmd = [
|
cmd = [
|
||||||
'mkfs.vfat', '-F', '32',
|
'mkfs.vfat', '-F', '32',
|
||||||
'-n', label,
|
'-n', label,
|
||||||
part_path,
|
find_first_partition(dev_path),
|
||||||
]
|
]
|
||||||
try_and_print(
|
try_and_print(
|
||||||
message='Formatting partition...',
|
message='Formatting partition...',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue