From f6b68cbd3d649c4abfea80939289bb7f1e925db6 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 19 Feb 2019 08:43:21 -0800 Subject: [PATCH] Add some extra cancel_func protection to QEMUInstall In livemedia-creator's usage of this it can never pass in None, but if someone were to import the library and use it, it would crash with NoneType. So add the extra checks to make sure cancel_func isn't None, just in case. (cherry picked from commit 9041174142e138aff13dcc23b46e4c53e1c410dd) --- src/pylorax/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pylorax/installer.py b/src/pylorax/installer.py index 36fba3cd..51e6302b 100644 --- a/src/pylorax/installer.py +++ b/src/pylorax/installer.py @@ -249,7 +249,7 @@ class QEMUInstall(object): log.debug(qemu_cmd) try: execWithRedirect(qemu_cmd[0], qemu_cmd[1:], reset_lang=False, raise_err=True, - callback=lambda p: not cancel_func()) + callback=lambda p: not (cancel_func and cancel_func())) except subprocess.CalledProcessError as e: log.error("Running qemu failed:") log.error("cmd: %s", " ".join(e.cmd)) @@ -263,7 +263,7 @@ class QEMUInstall(object): if boot_uefi and ovmf_path: os.unlink(ovmf_vars) - if cancel_func(): + if cancel_func and cancel_func(): log.error("Installation error detected. See logfile for details.") raise InstallError("QEMUInstall failed") else: