Repository: servo/servo
File: python/servo/platform/windows.py (Python)

Code before:
        # a user installed version without good reason.
        cmd = ["winget", "install"]
        if not yes:
            cmd.append("--interactive")
        if force:
            cmd.append("--force")
        else:
            cmd.append("--no-upgrade")

        cmd.extend(WINGET_DEPENDENCIES)

        # The output will be printed to the terminal that `./mach bootstrap` is running in.
        subprocess.run(cmd, encoding="utf-8")
    except subprocess.CalledProcessError as e:
        print("Could not run winget.  Follow manual build setup instructions.")
        raise e


def _choco_install(force: bool = False, yes: bool = False) -> None:
    try:
        choco_config = os.path.join(util.SERVO_ROOT, "support", "windows", "chocolatey.config")

        # This is the format that PowerShell wants arguments passed to it.
        cmd_exe_args = "'/K','choco','install'"
        if force or yes:
            cmd_exe_args += ",'-y'"
        cmd_exe_args += f", '\"{choco_config}\"'"
        if force:
            cmd_exe_args += ",'-f'"

        print(cmd_exe_args)
        subprocess.check_output(
            ["powershell", "Start-Process", "-Wait", "-verb", "runAs", "cmd.exe", "-ArgumentList", f"@({cmd_exe_args})"]
        ).decode("utf-8")
    except subprocess.CalledProcessError as e:
        print("Could not run chocolatey.  Follow manual build setup instructions.")
        raise e


class Windows(Base):
    def __init__(self, triple: str) -> None:
        super().__init__(triple)
        self.is_windows = True

    def executable_suffix(self) -> str:
        return ".exe"

    @classmethod
    def download_and_extract_dependency(cls, zip_path: str, full_spec: str) -> None:
        if not os.path.isfile(zip_path):
            zip_url = f"{DEPS_URL}/{urllib.parse.quote(full_spec)}.zip"

Review comment (suggestion):
I suspect we always want to keep passing `-y` `choco`. There's no reason to make `.\mach boostrap` more annoying just because the user didn't pass `-y`. I believe that `choco` is quite chatty so the `-y` here really improved the usability of the command.

Code after:
        # a user installed version without good reason.
        cmd = ["winget", "install"]
        if not yes:
            cmd.append("--interactive")
        if force:
            cmd.append("--force")
        else:
            cmd.append("--no-upgrade")

        cmd.extend(WINGET_DEPENDENCIES)

        # The output will be printed to the terminal that `./mach bootstrap` is running in.
        subprocess.run(cmd, encoding="utf-8")
    except subprocess.CalledProcessError as e:
        print("Could not run winget.  Follow manual build setup instructions.")
        raise e


def _choco_install(force: bool = False) -> None:
    try:
        choco_config = os.path.join(util.SERVO_ROOT, "support", "windows", "chocolatey.config")

        # This is the format that PowerShell wants arguments passed to it.
        cmd_exe_args = f"'/K','choco','install','-y', '\"{choco_config}\"'"
        if force:
            cmd_exe_args += ",'-f'"

        print(cmd_exe_args)
        subprocess.check_output(
            ["powershell", "Start-Process", "-Wait", "-verb", "runAs", "cmd.exe", "-ArgumentList", f"@({cmd_exe_args})"]
        ).decode("utf-8")
    except subprocess.CalledProcessError as e:
        print("Could not run chocolatey.  Follow manual build setup instructions.")
        raise e


class Windows(Base):
    def __init__(self, triple: str) -> None:
        super().__init__(triple)
        self.is_windows = True

    def executable_suffix(self) -> str:
        return ".exe"

    @classmethod
    def download_and_extract_dependency(cls, zip_path: str, full_spec: str) -> None:
        if not os.path.isfile(zip_path):
            zip_url = f"{DEPS_URL}/{urllib.parse.quote(full_spec)}.zip"
            util.download_file(full_spec, zip_url, zip_path)

        zip_dir = os.path.dirname(zip_path)