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.

Related: rhbz#1684316
This commit is contained in:
Brian C. Lane 2019-02-19 08:43:21 -08:00
parent 3d376764d4
commit 2f8fb6fa8e

View File

@ -243,7 +243,7 @@ class QEMUInstall(object):
log.debug(qemu_cmd) log.debug(qemu_cmd)
try: try:
execWithRedirect(qemu_cmd[0], qemu_cmd[1:], reset_lang=False, raise_err=True, 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: except subprocess.CalledProcessError as e:
log.error("Running qemu failed:") log.error("Running qemu failed:")
log.error("cmd: %s", " ".join(e.cmd)) log.error("cmd: %s", " ".join(e.cmd))
@ -257,7 +257,7 @@ class QEMUInstall(object):
if boot_uefi and ovmf_path: if boot_uefi and ovmf_path:
os.unlink(ovmf_vars) os.unlink(ovmf_vars)
if cancel_func(): if cancel_func and cancel_func():
log.error("Installation error detected. See logfile for details.") log.error("Installation error detected. See logfile for details.")
raise InstallError("QEMUInstall failed") raise InstallError("QEMUInstall failed")
else: else: