Backed out changeset 9b5ebc2d3b4b (bug 1877347) as requested by Aryx on element. CLOSED TREE

This commit is contained in:
Cristian Tuns 2024-02-09 18:51:43 -05:00
parent 664c1ecf7c
commit ac412e192f
5 changed files with 17 additions and 20 deletions

View File

@ -115,18 +115,3 @@ def to_optional_str(path: Optional[Path]):
return str(path)
else:
return None
def strtobool(value: str):
# Reimplementation of distutils.util.strtobool
# https://docs.python.org/3.9/distutils/apiref.html#distutils.util.strtobool
true_vals = ("y", "yes", "t", "true", "on", "1")
false_vals = ("n", "no", "f", "false", "off", "0")
value = value.lower()
if value in true_vals:
return 1
if value in false_vals:
return 0
raise ValueError(f'Expected one of: {", ".join(true_vals + false_vals)}')

View File

@ -409,7 +409,7 @@ def get_clang_tools(command_context, clang_tools_path):
def prompt_bool(prompt, limit=5):
"""Prompts the user with prompt and requires a boolean value."""
from mach.util import strtobool
from distutils.util import strtobool
for _ in range(limit):
try:

View File

@ -51,7 +51,7 @@ def build_repo_relative_path(abs_path, repo_path):
def prompt_bool(prompt, limit=5):
"""Prompts the user with prompt and requires a boolean value."""
from mach.util import strtobool
from distutils.util import strtobool
for _ in range(limit):
try:

View File

@ -13,10 +13,10 @@ import shutil
import tempfile
import time
from contextlib import AsyncExitStack
from distutils.util import strtobool
from pathlib import Path
import aiohttp
from mach.util import strtobool
from mardor.reader import MarReader
from mardor.signing import get_keysize
from scriptworker.utils import get_hash, retry_async

View File

@ -17,11 +17,23 @@ from functools import partial
import gecko_taskgraph.main
from gecko_taskgraph.main import commands as taskgraph_commands
from mach.decorators import Command, CommandArgument, SubCommand
from mach.util import strtobool
logger = logging.getLogger("taskcluster")
def strtobool(value):
"""Convert string to boolean.
Wraps "distutils.util.strtobool", deferring the import of the package
in case it's not installed. Otherwise, we have a "chicken and egg problem" where
|mach bootstrap| would install the required package to enable "distutils.util", but
it can't because mach fails to interpret this file.
"""
from distutils.util import strtobool
return bool(strtobool(value))
def get_taskgraph_command_parser(name):
"""Given a command name, obtain its argument parser.
@ -47,7 +59,7 @@ def get_taskgraph_decision_parser():
(
["--optimize-target-tasks"],
{
"type": lambda flag: bool(strtobool(flag)),
"type": lambda flag: strtobool(flag),
"nargs": "?",
"const": "true",
"help": "If specified, this indicates whether the target "