This commit is contained in:
parent
47bcc66773
commit
2d513bbcab
8015
TeamTalk_DLL/TeamTalk.h
Normal file
8015
TeamTalk_DLL/TeamTalk.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
TeamTalk_DLL/TeamTalk5.lib
Normal file
BIN
TeamTalk_DLL/TeamTalk5.lib
Normal file
Binary file not shown.
@ -9,43 +9,38 @@ import platform
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
# Setup path
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
path = os.path.dirname(path)
|
||||
sys.path.append(path)
|
||||
import downloader
|
||||
|
||||
|
||||
url = "https://bearware.dk/teamtalksdk"
|
||||
|
||||
|
||||
|
||||
def get_url_suffix_from_platform() -> str:
|
||||
machine = platform.machine()
|
||||
if sys.platform == "win32":
|
||||
architecture = platform.architecture()
|
||||
if machine == "AMD64" or machine == "x86":
|
||||
if architecture[0] == "64bit":
|
||||
return "win64"
|
||||
else:
|
||||
return "win32"
|
||||
if machine in ["AMD64", "x86"]:
|
||||
return "win64" if architecture[0] == "64bit" else "win32"
|
||||
else:
|
||||
sys.exit("Native Windows on ARM is not supported")
|
||||
sys.exit("Native Windows on ARM is not supported.")
|
||||
elif sys.platform == "darwin":
|
||||
sys.exit("Darwin is not supported")
|
||||
sys.exit("macOS is not supported.")
|
||||
else:
|
||||
if machine == "AMD64" or machine == "x86_64":
|
||||
if machine in ["AMD64", "x86_64"]:
|
||||
return "ubuntu18_x86_64"
|
||||
elif "arm" in machine:
|
||||
return "raspbian_armhf"
|
||||
else:
|
||||
sys.exit("Your architecture is not supported")
|
||||
sys.exit("Your system architecture is not supported.")
|
||||
|
||||
|
||||
def download() -> None:
|
||||
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
|
||||
headers = {'User-Agent': 'Mozilla/5.0'}
|
||||
r = requests.get(url, headers=headers)
|
||||
page = bs4.BeautifulSoup(r.text, features="html.parser")
|
||||
# The last tested version series is v5.12x
|
||||
versions = page.find_all("li")
|
||||
version = [i for i in versions if "5.12" in i.text][-1].a.get("href")[0:-1]
|
||||
download_url = (
|
||||
@ -55,7 +50,7 @@ def download() -> None:
|
||||
+ "/"
|
||||
+ "tt5sdk_{v}_{p}.7z".format(v=version, p=get_url_suffix_from_platform())
|
||||
)
|
||||
print("Downloading from " + download_url)
|
||||
print("Downloading from: " + download_url)
|
||||
downloader.download_file(download_url, os.path.join(os.getcwd(), "ttsdk.7z"))
|
||||
|
||||
|
||||
@ -66,32 +61,51 @@ def extract() -> None:
|
||||
shutil.rmtree(os.path.join(os.getcwd(), "ttsdk"))
|
||||
os.mkdir(os.path.join(os.getcwd(), "ttsdk"))
|
||||
patoolib.extract_archive(
|
||||
os.path.join(os.getcwd(), "ttsdk.7z"), outdir=os.path.join(os.getcwd(), "ttsdk")
|
||||
os.path.join(os.getcwd(), "ttsdk.7z"),
|
||||
outdir=os.path.join(os.getcwd(), "ttsdk")
|
||||
)
|
||||
|
||||
|
||||
def move() -> None:
|
||||
path = os.path.join(os.getcwd(), "ttsdk", os.listdir(os.path.join(os.getcwd(), "ttsdk"))[0])
|
||||
sdk_root = os.path.join(os.getcwd(), "ttsdk")
|
||||
contents = os.listdir(sdk_root)
|
||||
|
||||
if not contents:
|
||||
raise RuntimeError("SDK extraction failed: 'ttsdk/' folder is empty.")
|
||||
|
||||
for entry in contents:
|
||||
entry_path = os.path.join(sdk_root, entry)
|
||||
if os.path.isdir(entry_path) and os.path.isdir(os.path.join(entry_path, "Library")):
|
||||
path = entry_path
|
||||
break
|
||||
else:
|
||||
raise RuntimeError("No 'Library' folder found in extracted SDK.")
|
||||
|
||||
libraries = ["TeamTalk_DLL", "TeamTalkPy"]
|
||||
dest_dir = os.path.join(os.getcwd(), os.pardir) if os.path.basename(os.getcwd()) == "tools" else os.getcwd()
|
||||
|
||||
for library in libraries:
|
||||
src = os.path.join(path, "Library", library)
|
||||
dst = os.path.join(dest_dir, library)
|
||||
|
||||
if not os.path.exists(src):
|
||||
print(f"WARNING: {library} not found.")
|
||||
continue
|
||||
|
||||
try:
|
||||
os.rename(
|
||||
os.path.join(path, "Library", library), os.path.join(dest_dir, library)
|
||||
)
|
||||
os.rename(src, dst)
|
||||
except OSError:
|
||||
shutil.rmtree(os.path.join(dest_dir, library))
|
||||
os.rename(
|
||||
os.path.join(path, "Library", library), os.path.join(dest_dir, library)
|
||||
)
|
||||
try:
|
||||
os.rename(
|
||||
os.path.join(path, "License.txt"), os.path.join(dest_dir, "TTSDK_license.txt")
|
||||
)
|
||||
except FileExistsError:
|
||||
os.remove(os.path.join(dest_dir, "TTSDK_license.txt"))
|
||||
os.rename(
|
||||
os.path.join(path, "License.txt"), os.path.join(dest_dir, "TTSDK_license.txt")
|
||||
)
|
||||
if os.path.exists(dst):
|
||||
shutil.rmtree(dst)
|
||||
os.rename(src, dst)
|
||||
|
||||
license_path = os.path.join(path, "License.txt")
|
||||
dst_license = os.path.join(dest_dir, "TTSDK_license.txt")
|
||||
|
||||
if os.path.exists(license_path):
|
||||
if os.path.exists(dst_license):
|
||||
os.remove(dst_license)
|
||||
os.rename(license_path, dst_license)
|
||||
|
||||
|
||||
def clean() -> None:
|
||||
@ -100,17 +114,17 @@ def clean() -> None:
|
||||
|
||||
|
||||
def install() -> None:
|
||||
print("Installing TeamTalk sdk components")
|
||||
print("Downloading latest sdk version")
|
||||
print("Starting TeamTalk SDK installation...")
|
||||
print("Downloading the latest SDK version...")
|
||||
download()
|
||||
print("Downloaded. extracting")
|
||||
print("Download complete. Extracting...")
|
||||
extract()
|
||||
print("Extracted. moving")
|
||||
print("Extraction complete. Moving files...")
|
||||
move()
|
||||
print("moved. cleaning")
|
||||
print("Move complete. Cleaning up...")
|
||||
clean()
|
||||
print("cleaned.")
|
||||
print("Installed")
|
||||
print("Cleanup done.")
|
||||
print("TeamTalk SDK successfully installed.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user