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,
|
"wibo": wibo_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def download(url, response, output) -> None:
|
def download(url, response, output) -> None:
|
||||||
if url.endswith(".zip"):
|
if url.endswith(".zip"):
|
||||||
data = io.BytesIO(response.read())
|
data = io.BytesIO(response.read())
|
||||||
@ -107,6 +108,7 @@ def download(url, response, output) -> None:
|
|||||||
st = os.stat(output)
|
st = os.stat(output)
|
||||||
os.chmod(output, st.st_mode | stat.S_IEXEC)
|
os.chmod(output, st.st_mode | stat.S_IEXEC)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("tool", help="Tool name")
|
parser.add_argument("tool", help="Tool name")
|
||||||
@ -128,12 +130,17 @@ def main() -> None:
|
|||||||
try:
|
try:
|
||||||
import certifi
|
import certifi
|
||||||
import ssl
|
import ssl
|
||||||
except:
|
except ImportError:
|
||||||
print("\"certifi\" module not found. Please install it using \"python -m pip install certifi\".")
|
print(
|
||||||
|
'"certifi" module not found. Please install it using "python -m pip install certifi".'
|
||||||
|
)
|
||||||
return
|
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)
|
download(url, response, output)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user