forked from CrazyLegsSteph/ShortCommands
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.py
More file actions
29 lines (25 loc) · 777 Bytes
/
Copy pathbootstrap.py
File metadata and controls
29 lines (25 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import subprocess
import os
import sys
from pathlib import Path
import urllib.request
import zipfile
import io
import shutil
import shlex
import re
from typing import Optional, Union, Collection, Set
OptionalPath = Union[None, Path, str]
def download_tshock(url=r"https://github.com/Pryaxis/TShock/releases/download/v4.4.0-pre11/TShock4.4.0_Pre11_Terraria1.4.0.5.zip", dest: OptionalPath=None):
if dest is None:
dest = "./TShock"
dest: Path = Path(dest)
with urllib.request.urlopen(url) as response:
buff = io.BytesIO()
shutil.copyfileobj(response, buff)
buff.seek(0)
with zipfile.ZipFile(buff) as zf:
dest.mkdir(exist_ok=True)
zf.extractall(dest)
if __name__ == "__main__":
download_tshock()