| 93 | |
| 94 | |
| 95 | def download(url, response, output) -> None: |
| 96 | if url.endswith(".zip"): |
| 97 | data = io.BytesIO(response.read()) |
| 98 | with zipfile.ZipFile(data) as f: |
| 99 | f.extractall(output) |
| 100 | # Make all files executable |
| 101 | for root, _, files in os.walk(output): |
| 102 | for name in files: |
| 103 | os.chmod(os.path.join(root, name), 0o755) |
| 104 | output.touch(mode=0o755) # Update dir modtime |
| 105 | else: |
| 106 | with open(output, "wb") as f: |
| 107 | shutil.copyfileobj(response, f) |
| 108 | st = os.stat(output) |
| 109 | os.chmod(output, st.st_mode | stat.S_IEXEC) |
| 110 | |
| 111 | |
| 112 | def main() -> None: |