enforce E501 in pmb/flasher (MR 2058)

This commit is contained in:
Caio Fontes 2021-05-19 15:55:40 -03:00 committed by Oliver Smith
parent aaece05bb7
commit cfa5bc2cf7
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
4 changed files with 37 additions and 22 deletions

View file

@ -31,10 +31,12 @@ def kernel(args):
pmb.flasher.run(args, "flash_kernel", flavor)
logging.info("You will get an IP automatically assigned to your "
"USB interface shortly.")
logging.info("Then you can connect to your device using ssh after pmOS has booted:")
logging.info("Then you can connect to your device using ssh after pmOS has"
" booted:")
logging.info("ssh {}@{}".format(args.user, pmb.config.default_ip))
logging.info("NOTE: If you enabled full disk encryption, you should make sure that"
" osk-sdl has been properly configured for your device")
logging.info("NOTE: If you enabled full disk encryption, you should make"
" sure that osk-sdl has been properly configured for your"
" device")
def list_flavors(args):
@ -52,13 +54,15 @@ def rootfs(args):
if pmb.config.flashers.get(method, {}).get("split", False):
suffix = "-root.img"
img_path = args.work + "/chroot_native/home/pmos/rootfs/" + args.device + suffix
img_path = f"{args.work}/chroot_native/home/pmos/rootfs/{args.device}"\
f"{suffix}"
if not os.path.exists(img_path):
raise RuntimeError("The rootfs has not been generated yet, please run"
" 'pmbootstrap install' first.")
# Do not flash if using fastboot & image is too large
if method.startswith("fastboot") and args.deviceinfo["flash_fastboot_max_size"]:
if method.startswith("fastboot") \
and args.deviceinfo["flash_fastboot_max_size"]:
img_size = os.path.getsize(img_path) / 1024**2
max_size = int(args.deviceinfo["flash_fastboot_max_size"])
if img_size > max_size:

View file

@ -13,11 +13,13 @@ def init(args):
method = args.deviceinfo["flash_method"]
if method not in pmb.config.flashers:
raise RuntimeError("Flash method " + method + " is not supported by the"
" current configuration. However, adding a new flash method is "
" not that hard, when the flashing application already exists.\n"
"Make sure, it is packaged for Alpine Linux, or package it "
" yourself, and then add it to pmb/config/__init__.py.")
raise RuntimeError(f"Flash method {method} is not supported by the"
" current configuration. However, adding a new"
" flash method is not that hard, when the flashing"
" application already exists.\n"
"Make sure, it is packaged for Alpine Linux, or"
" package it yourself, and then add it to"
" pmb/config/__init__.py.")
cfg = pmb.config.flashers[method]
# Install depends

View file

@ -49,10 +49,11 @@ def run(args, action, flavor=None):
for i in range(len(command)):
if key in command[i]:
if value is None:
raise RuntimeError("Variable " + key + " found in"
" action " + action + " for method " + method + ","
" but the value for this variable is None! Is that"
" missing in your deviceinfo?")
raise RuntimeError(f"Variable {key} found in action"
f" {action} for method {method},"
" but the value for this variable"
" is None! Is that missing in your"
" deviceinfo?")
check_partition_blacklist(args, key, value)
command[i] = command[i].replace(key, value)

View file

@ -10,16 +10,23 @@ def variables(args, flavor, method):
flash_pagesize = args.deviceinfo['flash_pagesize']
if method.startswith("fastboot"):
_partition_kernel = args.deviceinfo["flash_fastboot_partition_kernel"] or "boot"
_partition_system = args.deviceinfo["flash_fastboot_partition_system"] or "system"
_partition_vbmeta = args.deviceinfo["flash_fastboot_partition_vbmeta"] or None
_partition_kernel = args.deviceinfo["flash_fastboot_partition_kernel"]\
or "boot"
_partition_system = args.deviceinfo["flash_fastboot_partition_system"]\
or "system"
_partition_vbmeta = args.deviceinfo["flash_fastboot_partition_vbmeta"]\
or None
else:
_partition_kernel = args.deviceinfo["flash_heimdall_partition_kernel"] or "KERNEL"
_partition_system = args.deviceinfo["flash_heimdall_partition_system"] or "SYSTEM"
_partition_vbmeta = args.deviceinfo["flash_heimdall_partition_vbmeta"] or None
_partition_kernel = args.deviceinfo["flash_heimdall_partition_kernel"]\
or "KERNEL"
_partition_system = args.deviceinfo["flash_heimdall_partition_system"]\
or "SYSTEM"
_partition_vbmeta = args.deviceinfo["flash_heimdall_partition_vbmeta"]\
or None
if "partition" in args and args.partition:
# Only one of operations is done at same time so it doesn't matter sharing the arg
# Only one of operations is done at same time so it doesn't matter
# sharing the arg
_partition_kernel = args.partition
_partition_system = args.partition
_partition_vbmeta = args.partition
@ -37,7 +44,8 @@ def variables(args, flavor, method):
"$IMAGE": "/home/pmos/rootfs/" + args.device + ".img",
"$KERNEL_CMDLINE": _cmdline,
"$PARTITION_KERNEL": _partition_kernel,
"$PARTITION_INITFS": args.deviceinfo["flash_heimdall_partition_initfs"] or "RECOVERY",
"$PARTITION_INITFS": args.deviceinfo[
"flash_heimdall_partition_initfs"] or "RECOVERY",
"$PARTITION_SYSTEM": _partition_system,
"$PARTITION_VBMETA": _partition_vbmeta,
"$FLASH_PAGESIZE": flash_pagesize,