diff --git a/image_creator/os_type/windows.py b/image_creator/os_type/windows.py index 7c4c127220289eec9f76119c30b16872a0fdb6ff..b758e034e4443d4b74490c5ef3481d13ef279877 100644 --- a/image_creator/os_type/windows.py +++ b/image_creator/os_type/windows.py @@ -139,6 +139,11 @@ class Windows(OSBase): raise FatalError( 'For windows support libguestfs 1.16.11 or above is required') + # Check if winexe is installed + if not WinEXE.is_installed(): + raise FatalError( + "For windows support `Winexe' needs to be installed") + device = self.image.g.part_to_dev(self.root) self.last_part_num = self.image.g.part_list(device)[-1]['part_num'] diff --git a/image_creator/winexe.py b/image_creator/winexe.py index ebac40931b0671cc08fea8518d58411b13faeb1c..b6c00bc3a5c30a96919d9bb40bd0e9282bb3042e 100644 --- a/image_creator/winexe.py +++ b/image_creator/winexe.py @@ -38,6 +38,7 @@ import subprocess import time import signal +import distutils from image_creator.util import FatalError @@ -50,6 +51,10 @@ class WinexeTimeout(FatalError): class WinEXE: """Wrapper class for the winexe command""" + @staticmethod + def is_installed(program='winexe'): + return distutils.spawn.find_executable(program) is not None + def __init__(self, username, password, hostname, program='winexe'): self._host = hostname self._user = username