| 104 | |
| 105 | |
| 106 | def download(url, response, output) -> None: |
| 107 | if url.endswith(".zip"): |
| 108 | data = io.BytesIO(response.read()) |
| 109 | with zipfile.ZipFile(data) as f: |
| 110 | f.extractall(output) |
| 111 | # Make all files executable |
| 112 | for root, _, files in os.walk(output): |
| 113 | for name in files: |
| 114 | os.chmod(os.path.join(root, name), 0o755) |
| 115 | output.touch(mode=0o755) # Update dir modtime |
| 116 | else: |
| 117 | with open(output, "wb") as f: |
| 118 | shutil.copyfileobj(response, f) |
| 119 | st = os.stat(output) |
| 120 | os.chmod(output, st.st_mode | stat.S_IEXEC) |
| 121 | |
| 122 | |
| 123 | def main() -> None: |