MCPcopy Create free account
hub / github.com/doldecomp/mkdd / main

Function main

tools/download_tool.py:112–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

110
111
112def main() -> None:
113 parser = argparse.ArgumentParser()
114 parser.add_argument("tool", help="Tool name")
115 parser.add_argument("output", type=Path, help="output file path")
116 parser.add_argument("--tag", help="GitHub tag", required=True)
117 args = parser.parse_args()
118
119 url = TOOLS[args.tool](args.tag)
120 output = Path(args.output)
121
122 print(f"Downloading {url} to {output}")
123 req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
124 try:
125 with urllib.request.urlopen(req) as response:
126 download(url, response, output)
127 except urllib.error.URLError as e:
128 if str(e).find("CERTIFICATE_VERIFY_FAILED") == -1:
129 raise e
130 try:
131 import certifi
132 import ssl
133 except ImportError:
134 print(
135 '"certifi" module not found. Please install it using "python -m pip install certifi".'
136 )
137 return
138
139 with urllib.request.urlopen(
140 req, context=ssl.create_default_context(cafile=certifi.where())
141 ) as response:
142 download(url, response, output)
143
144
145if __name__ == "__main__":

Callers 1

download_tool.pyFile · 0.70

Calls 2

downloadFunction · 0.85
findMethod · 0.80

Tested by

no test coverage detected