Skip to content

Commit fec03ef

Browse files
authored
Merge pull request #89 from nathanchance/new-pylint
boot-utils: Fix new pylint warnings
2 parents 1b837f3 + 0709eae commit fec03ef

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

boot-qemu.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ def get_efi_args(guest_arch):
398398

399399
for efi_img_location in efi_img_locations[guest_arch]:
400400
if efi_img_location is None:
401-
raise Exception(f"edk2 could not be found for {guest_arch}!")
401+
raise FileNotFoundError(
402+
f"edk2 could not be found for {guest_arch}!")
402403
efi_img = Path("/usr/share", efi_img_location)
403404
if efi_img.exists():
404405
break
@@ -410,12 +411,14 @@ def get_efi_args(guest_arch):
410411

411412
efi_img_qemu = base_folder.joinpath("images", guest_arch, "efi.img")
412413
shutil.copyfile(efi_img, efi_img_qemu)
413-
efi_img_qemu.open(mode="r+b").truncate(efi_img_size)
414+
with efi_img_qemu.open(mode="r+b") as file:
415+
file.truncate(efi_img_size)
414416

415417
efi_vars_qemu = base_folder.joinpath("images", guest_arch,
416418
"efivars.img")
417419
efi_vars_qemu.unlink(missing_ok=True)
418-
efi_vars_qemu.open(mode="xb").truncate(efi_img_size)
420+
with efi_vars_qemu.open(mode="xb") as file:
421+
file.truncate(efi_img_size)
419422

420423
elif guest_arch == "x86_64":
421424
efi_img_qemu = efi_img # This is just usable, it is marked read only
@@ -428,7 +431,7 @@ def get_efi_args(guest_arch):
428431
]
429432
for efi_vars_location in efi_vars_locations:
430433
if efi_vars_location is None:
431-
raise Exception("OVMF_VARS.fd could not be found!")
434+
raise FileNotFoundError("OVMF_VARS.fd could not be found!")
432435
efi_vars = Path('/usr/share', efi_vars_location)
433436
if efi_vars.exists():
434437
break

0 commit comments

Comments
 (0)