mirror of https://github.com/zulip/zulip.git
python: Use Python 3.8 shlex.join function.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
71390fb635
commit
098a514599
|
@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
def run(args: List[str], dry_run: bool = False) -> str:
|
||||
if dry_run:
|
||||
print("Would have run: " + " ".join(map(shlex.quote, args)))
|
||||
print(f"Would have run: {shlex.join(args)}")
|
||||
return ""
|
||||
|
||||
return subprocess.check_output(args, stdin=subprocess.DEVNULL, text=True)
|
||||
|
|
|
@ -227,19 +227,14 @@ def release_deployment_lock() -> None:
|
|||
|
||||
def run(args: Sequence[str], **kwargs: Any) -> None:
|
||||
# Output what we're doing in the `set -x` style
|
||||
print("+ {}".format(" ".join(map(shlex.quote, args))), flush=True)
|
||||
print(f"+ {shlex.join(args)}", flush=True)
|
||||
|
||||
try:
|
||||
subprocess.check_call(args, **kwargs)
|
||||
except subprocess.CalledProcessError:
|
||||
print()
|
||||
print(
|
||||
WHITEONRED
|
||||
+ "Error running a subcommand of {}: {}".format(
|
||||
sys.argv[0],
|
||||
" ".join(map(shlex.quote, args)),
|
||||
)
|
||||
+ ENDC
|
||||
WHITEONRED + f"Error running a subcommand of {sys.argv[0]}: {shlex.join(args)}" + ENDC
|
||||
)
|
||||
print(WHITEONRED + "Actual error output for the subcommand is just above this." + ENDC)
|
||||
print()
|
||||
|
@ -258,7 +253,7 @@ def log_management_command(cmd: Sequence[str], log_path: str) -> None:
|
|||
logger.addHandler(file_handler)
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
logger.info("Ran %s", " ".join(map(shlex.quote, cmd)))
|
||||
logger.info("Ran %s", shlex.join(cmd))
|
||||
|
||||
|
||||
def get_environment() -> str:
|
||||
|
@ -567,7 +562,7 @@ def get_config_file() -> configparser.RawConfigParser:
|
|||
|
||||
|
||||
def get_deploy_options(config_file: configparser.RawConfigParser) -> List[str]:
|
||||
return shlex.split(get_config(config_file, "deployment", "deploy_options", "").strip())
|
||||
return shlex.split(get_config(config_file, "deployment", "deploy_options", ""))
|
||||
|
||||
|
||||
def run_psql_as_postgres(
|
||||
|
@ -575,20 +570,7 @@ def run_psql_as_postgres(
|
|||
sql_query: str,
|
||||
) -> None:
|
||||
dbname = get_config(config_file, "postgresql", "database_name", "zulip")
|
||||
subcmd = " ".join(
|
||||
map(
|
||||
shlex.quote,
|
||||
[
|
||||
"psql",
|
||||
"-v",
|
||||
"ON_ERROR_STOP=1",
|
||||
"-d",
|
||||
dbname,
|
||||
"-c",
|
||||
sql_query,
|
||||
],
|
||||
)
|
||||
)
|
||||
subcmd = shlex.join(["psql", "-v", "ON_ERROR_STOP=1", "-d", dbname, "-c", sql_query])
|
||||
subprocess.check_call(["su", "postgres", "-c", subcmd])
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ def run(check_func: Callable[[], bool]) -> None:
|
|||
|
||||
|
||||
def run_command(args: List[str]) -> None:
|
||||
print(" ".join(map(shlex.quote, args)))
|
||||
print(shlex.join(args))
|
||||
subprocess.check_call(args)
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ def exit(message: str) -> None:
|
|||
|
||||
|
||||
def run(command: List[str]) -> None:
|
||||
print("\n>>> " + " ".join(map(shlex.quote, command)))
|
||||
print(f"\n>>> {shlex.join(command)}")
|
||||
subprocess.check_call(command)
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ def run_single_test(test_file: str, test_number: int, total_tests: int) -> int:
|
|||
]
|
||||
|
||||
test_name = os.path.basename(test_file)
|
||||
cmd_str = " ".join(map(shlex.quote, cmd))
|
||||
cmd_str = shlex.join(cmd)
|
||||
print(
|
||||
f"\n\n===================== ({test_number}/{total_tests}) {test_name} =====================\nRunning {cmd_str}\n\n",
|
||||
flush=True,
|
||||
|
|
|
@ -300,7 +300,7 @@ def generate_curl_example(
|
|||
example_endpoint = endpoint.format_map(format_dict)
|
||||
|
||||
curl_first_line_parts = ["curl", *curl_method_arguments(example_endpoint, method, api_url)]
|
||||
lines.append(" ".join(map(shlex.quote, curl_first_line_parts)))
|
||||
lines.append(shlex.join(curl_first_line_parts))
|
||||
|
||||
insecure_operations = ["/dev_fetch_api_key:post", "/fetch_api_key:post"]
|
||||
if operation_security is None:
|
||||
|
|
|
@ -67,9 +67,7 @@ def webathena_kerberos_login(
|
|||
api_key,
|
||||
base64.b64encode(ccache).decode(),
|
||||
]
|
||||
subprocess.check_call(
|
||||
["ssh", settings.PERSONAL_ZMIRROR_SERVER, "--", " ".join(map(shlex.quote, command))]
|
||||
)
|
||||
subprocess.check_call(["ssh", settings.PERSONAL_ZMIRROR_SERVER, "--", shlex.join(command)])
|
||||
except subprocess.CalledProcessError:
|
||||
logging.exception("Error updating the user's ccache", stack_info=True)
|
||||
raise JsonableError(_("We were unable to set up mirroring for you"))
|
||||
|
|
Loading…
Reference in New Issue