Skip to content

Commit 8d6a276

Browse files
authored
Merge pull request #92 from nathanchance/update-ruff
Follow up fixes for ruff
2 parents 5ea50a4 + 6bbfed7 commit 8d6a276

4 files changed

Lines changed: 22 additions & 27 deletions

File tree

boot-qemu.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,28 @@ def parse_arguments():
7575
"--shell",
7676
action="store_true",
7777
help=
78-
"Instead of immediately shutting down the machine upon successful boot, pass 'rdinit=/bin/sh' on the kernel command line to allow interacting with the machine via a shell.",
78+
"Instead of immediately shutting down the machine upon successful boot, pass 'rdinit=/bin/sh' on the kernel command line to allow interacting with the machine via a shell."
7979
)
8080
parser.add_argument(
8181
"-k",
8282
"--kernel-location",
8383
required=True,
8484
type=str,
8585
help=
86-
"Path to kernel image or kernel build folder to search for image in. Can be an absolute or relative path.",
86+
"Path to kernel image or kernel build folder to search for image in. Can be an absolute or relative path."
8787
)
8888
parser.add_argument(
8989
"--no-kvm",
9090
action="store_true",
9191
help=
92-
"Do not use KVM for acceleration even when supported (only recommended for debugging).",
92+
"Do not use KVM for acceleration even when supported (only recommended for debugging)."
9393
)
9494
parser.add_argument(
9595
"-s",
9696
"--smp",
9797
type=int,
9898
help=
99-
"Number of processors for virtual machine. By default, only machines spawned with KVM will use multiple vCPUS.",
99+
"Number of processors for virtual machine. By default, only machines spawned with KVM will use multiple vCPUS."
100100
)
101101
parser.add_argument(
102102
"-t",
@@ -656,7 +656,7 @@ def get_qemu_args(cfg):
656656
dtb = kernel.parent.joinpath(dtb_dir, dtb)
657657
if not dtb.exists():
658658
utils.die(
659-
f"'{dtb.stem}' is required for booting but it could not be found at '{dtb}'",
659+
f"'{dtb.stem}' is required for booting but it could not be found at '{dtb}'"
660660
)
661661

662662
qemu_args += ["-dtb", dtb]
@@ -678,11 +678,10 @@ def get_qemu_args(cfg):
678678
qemu_args += ["-cpu", kvm_cpu]
679679
qemu_args += ["-enable-kvm"]
680680
qemu_args += ["-smp", str(smp_value)]
681-
else:
682-
# By default, we do not use '-smp' with TCG for performance reasons.
683-
# Only add it if the user explicitly requested it.
684-
if smp_requested:
685-
qemu_args += ["-smp", str(smp_value)]
681+
# By default, we do not use '-smp' with TCG for performance reasons.
682+
# Only add it if the user explicitly requested it.
683+
elif smp_requested:
684+
qemu_args += ["-smp", str(smp_value)]
686685

687686
# Other miscellaneous options
688687
qemu_args += ["-display", "none"]

boot-uml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ def parse_arguments():
2424
"--interactive",
2525
action="store_true",
2626
help=
27-
"Instead of immediately shutting down upon successful boot, pass 'init=/bin/sh' to the UML executable to allow interacting with UML via a shell.",
27+
"Instead of immediately shutting down upon successful boot, pass 'init=/bin/sh' to the UML executable to allow interacting with UML via a shell."
2828
)
2929
parser.add_argument(
3030
"-k",
3131
"--kernel-location",
3232
required=True,
3333
type=str,
3434
help=
35-
"Path to UML executable ('linux') or kernel build folder to search for executable in. Can be an absolute or relative path.",
35+
"Path to UML executable ('linux') or kernel build folder to search for executable in. Can be an absolute or relative path."
3636
)
3737

3838
return parser.parse_args()

ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
# https://beta.ruff.rs/docs/rules/
12
select = [
23
'A', # flake8-builtins
34
'ARG', # flake8-unused-arguments
45
'B', # flake8-bugbear
56
'C4', # flake8-comprehensions
6-
'COM', # flake8-commas
77
'E', # pycodestyle
88
'F', # pyflakes
99
'PIE', # flake8-pie

utils.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ def check_cmd(cmd):
1414
cmd (str): External command name or path.
1515
"""
1616
if not shutil.which(cmd):
17-
die(
18-
f"The external command '{cmd}' is needed but it could not be found in PATH, please install it!",
19-
)
17+
die(f"The external command '{cmd}' is needed but it could not be found in PATH, please install it!"
18+
)
2019

2120

2221
def die(string):
@@ -49,19 +48,16 @@ def get_full_kernel_path(kernel_location, image, arch=None):
4948
# If '-k' is a file, we can just use it directly
5049
if kernel_location.is_file():
5150
kernel = kernel_location
52-
# If not, we need to find it based on the kernel build directory
51+
# If the image is an uncompressed vmlinux or a UML image, it is in the
52+
# root of the build folder
53+
elif image in ("vmlinux", "linux"):
54+
kernel = kernel_location.joinpath(image)
55+
# Otherwise, it is in the architecture's boot directory
5356
else:
54-
# If the image is an uncompressed vmlinux or a UML image, it is in the
55-
# root of the build folder
56-
if image in ("vmlinux", "linux"):
57-
kernel = kernel_location.joinpath(image)
58-
# Otherwise, it is in the architecture's boot directory
59-
else:
60-
if not arch:
61-
die(
62-
f"Kernel image ('{image}') is in the arch/ directory but 'arch' was not provided!",
57+
if not arch:
58+
die(f"Kernel image ('{image}') is in the arch/ directory but 'arch' was not provided!"
6359
)
64-
kernel = kernel_location.joinpath("arch", arch, "boot", image)
60+
kernel = kernel_location.joinpath("arch", arch, "boot", image)
6561

6662
if not kernel.exists():
6763
die(f"Kernel ('{kernel}') does not exist!")

0 commit comments

Comments
 (0)