mirror of
https://github.com/encounter/dtk-template.git
synced 2025-10-28 03:40:23 +00:00
Format tools/download_tool.py
This commit is contained in:
parent
b4be7cfa39
commit
49b34faa6a
@ -91,6 +91,7 @@ TOOLS: Dict[str, Callable[[str], str]] = {
|
||||
"wibo": wibo_url,
|
||||
}
|
||||
|
||||
|
||||
def download(url, response, output) -> None:
|
||||
if url.endswith(".zip"):
|
||||
data = io.BytesIO(response.read())
|
||||
@ -107,6 +108,7 @@ def download(url, response, output) -> None:
|
||||
st = os.stat(output)
|
||||
os.chmod(output, st.st_mode | stat.S_IEXEC)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("tool", help="Tool name")
|
||||
@ -128,12 +130,17 @@ def main() -> None:
|
||||
try:
|
||||
import certifi
|
||||
import ssl
|
||||
except:
|
||||
print("\"certifi\" module not found. Please install it using \"python -m pip install certifi\".")
|
||||
except ImportError:
|
||||
print(
|
||||
'"certifi" module not found. Please install it using "python -m pip install certifi".'
|
||||
)
|
||||
return
|
||||
|
||||
with urllib.request.urlopen(req, context=ssl.create_default_context(cafile=certifi.where())) as response:
|
||||
|
||||
with urllib.request.urlopen(
|
||||
req, context=ssl.create_default_context(cafile=certifi.where())
|
||||
) as response:
|
||||
download(url, response, output)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user