From cfa5bc2cf7053eafd407b6604dc57870ee6be79a Mon Sep 17 00:00:00 2001 From: Caio Fontes Date: Wed, 19 May 2021 15:55:40 -0300 Subject: [PATCH] enforce E501 in pmb/flasher (MR 2058) --- pmb/flasher/frontend.py | 14 +++++++++----- pmb/flasher/init.py | 12 +++++++----- pmb/flasher/run.py | 9 +++++---- pmb/flasher/variables.py | 24 ++++++++++++++++-------- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/pmb/flasher/frontend.py b/pmb/flasher/frontend.py index 4955f62b..c9179081 100644 --- a/pmb/flasher/frontend.py +++ b/pmb/flasher/frontend.py @@ -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: diff --git a/pmb/flasher/init.py b/pmb/flasher/init.py index 502ccbb5..16e149a5 100644 --- a/pmb/flasher/init.py +++ b/pmb/flasher/init.py @@ -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 diff --git a/pmb/flasher/run.py b/pmb/flasher/run.py index 243b4cf1..fcd84b0e 100644 --- a/pmb/flasher/run.py +++ b/pmb/flasher/run.py @@ -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) diff --git a/pmb/flasher/variables.py b/pmb/flasher/variables.py index 1dea7a1a..8ae48cab 100644 --- a/pmb/flasher/variables.py +++ b/pmb/flasher/variables.py @@ -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,