def get_qemu_version(qemu_path):
        """
        Gets the Qemu version.

        :param qemu_path: path to Qemu executable.
        """

        if sys.platform.startswith("win"):
            # Qemu on Windows doesn't return anything with parameter -version
            # look for a version number in version.txt file in the same directory instead
            version_file = os.path.join(os.path.dirname(qemu_path), "version.txt")
            if os.path.isfile(version_file):
                try:
                    with open(version_file, "rb") as file:
                        version = file.read().decode("utf-8").strip()
                        match = re.search("[0-9\.]+", version)
                        if match:
                            return version
                except (UnicodeDecodeError, OSError) as e:
                    log.warn("could not read {}: {}".format(version_file, e))
            return ""
        else:
            try:
                output = yield from subprocess_check_output(qemu_path, "-version")
                match = re.search("version\s+([0-9a-z\-\.]+)", output)
                if match:
                    version = match.group(1)
                    return version
                else:
                    raise QemuError("Could not determine the Qemu version for {}".format(qemu_path))
            except subprocess.SubprocessError as e:
                raise QemuError("Error while looking for the Qemu version: {}".format(e))
def get_qemu_version ( qemu_path ) : if sys . platform . startswith ( "win" ) : version_file = os . path . join ( os . path . dirname ( qemu_path ) , "version.txt" ) if os . path . isfile ( version_file ) : try : with open ( version_file , "rb" ) as file : version = file . read ( ) . decode ( "utf-8" ) . strip ( ) match = re . search ( "[0-9\.]+" , version ) if match : return version except ( UnicodeDecodeError , OSError ) as e : log . warn ( "could not read {}: {}" . format ( version_file , e ) ) return "" else : try : output = yield from subprocess_check_output ( qemu_path , "-version" ) match = re . search ( "version\s+([0-9a-z\-\.]+)" , output ) if match : version = match . group ( 1 ) return version else : raise QemuError ( "Could not determine the Qemu version for {}" . format ( qemu_path ) ) except subprocess . SubprocessError as e : raise QemuError ( "Error while looking for the Qemu version: {}" . format ( e ) )
Gets the Qemu version.

        :param qemu_path: path to Qemu executable.