Fix query parameters in bench_download.py tool (#7772)

URL query parameter construction in the `bench_donwload.py` tool uses `urllib` to properly quote, e.g., complex branch names.

# Important Notes
Fixes queries with complicated branch names, like `./bench_download.py -v -s stdlib --use-cache true -b develop wip/akirathan/6959-Integer.+-cannot-be-invoked-statically`
This commit is contained in:
Pavel Marek 2023-09-08 17:33:23 +02:00 committed by GitHub
parent e0ee8fdda7
commit 294ee46af4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,6 +65,7 @@ from os import path
from typing import List, Dict, Optional, Any, Union, Set
from dataclasses import dataclass
import xml.etree.ElementTree as ET
from urllib.parse import urlencode
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 7):
@ -300,12 +301,11 @@ def _read_json(json_file: str) -> Dict[Any, Any]:
async def _invoke_gh_api(endpoint: str,
query_params: Dict[str, str] = {},
result_as_text: bool = True) -> Union[Dict[str, Any], bytes]:
query_str_list = [key + "=" + value for key, value in query_params.items()]
query_str = "&".join(query_str_list)
urlencode(query_params)
cmd = [
"gh",
"api",
f"/repos/enso-org/enso{endpoint}" + ("" if len(query_str) == 0 else "?" + query_str)
f"/repos/enso-org/enso{endpoint}" + "?" + urlencode(query_params)
]
logging.info(f"Starting subprocess `{' '.join(cmd)}`")
proc = await asyncio.create_subprocess_exec("gh", *cmd[1:],