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 shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
# Setup path
|
||||||
path = os.path.dirname(os.path.realpath(__file__))
|
path = os.path.dirname(os.path.realpath(__file__))
|
||||||
path = os.path.dirname(path)
|
path = os.path.dirname(path)
|
||||||
sys.path.append(path)
|
sys.path.append(path)
|
||||||
import downloader
|
import downloader
|
||||||
|
|
||||||
|
|
||||||
url = "https://bearware.dk/teamtalksdk"
|
url = "https://bearware.dk/teamtalksdk"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_url_suffix_from_platform() -> str:
|
def get_url_suffix_from_platform() -> str:
|
||||||
machine = platform.machine()
|
machine = platform.machine()
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
architecture = platform.architecture()
|
architecture = platform.architecture()
|
||||||
if machine == "AMD64" or machine == "x86":
|
if machine in ["AMD64", "x86"]:
|
||||||
if architecture[0] == "64bit":
|
return "win64" if architecture[0] == "64bit" else "win32"
|
||||||
return "win64"
|
|
||||||
else:
|
|
||||||
return "win32"
|
|
||||||
else:
|
else:
|
||||||
sys.exit("Native Windows on ARM is not supported")
|
sys.exit("Native Windows on ARM is not supported.")
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
sys.exit("Darwin is not supported")
|
sys.exit("macOS is not supported.")
|
||||||
else:
|
else:
|
||||||
if machine == "AMD64" or machine == "x86_64":
|
if machine in ["AMD64", "x86_64"]:
|
||||||
return "ubuntu18_x86_64"
|
return "ubuntu18_x86_64"
|
||||||
elif "arm" in machine:
|
elif "arm" in machine:
|
||||||
return "raspbian_armhf"
|
return "raspbian_armhf"
|
||||||
else:
|
else:
|
||||||
sys.exit("Your architecture is not supported")
|
sys.exit("Your system architecture is not supported.")
|
||||||
|
|
||||||
|
|
||||||
def download() -> None:
|
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)
|
r = requests.get(url, headers=headers)
|
||||||
page = bs4.BeautifulSoup(r.text, features="html.parser")
|
page = bs4.BeautifulSoup(r.text, features="html.parser")
|
||||||
# The last tested version series is v5.12x
|
|
||||||
versions = page.find_all("li")
|
versions = page.find_all("li")
|
||||||
version = [i for i in versions if "5.12" in i.text][-1].a.get("href")[0:-1]
|
version = [i for i in versions if "5.12" in i.text][-1].a.get("href")[0:-1]
|
||||||
download_url = (
|
download_url = (
|
||||||
@ -55,7 +50,7 @@ def download() -> None:
|
|||||||
+ "/"
|
+ "/"
|
||||||
+ "tt5sdk_{v}_{p}.7z".format(v=version, p=get_url_suffix_from_platform())
|
+ "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"))
|
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"))
|
shutil.rmtree(os.path.join(os.getcwd(), "ttsdk"))
|
||||||
os.mkdir(os.path.join(os.getcwd(), "ttsdk"))
|
os.mkdir(os.path.join(os.getcwd(), "ttsdk"))
|
||||||
patoolib.extract_archive(
|
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:
|
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"]
|
libraries = ["TeamTalk_DLL", "TeamTalkPy"]
|
||||||
dest_dir = os.path.join(os.getcwd(), os.pardir) if os.path.basename(os.getcwd()) == "tools" else os.getcwd()
|
dest_dir = os.path.join(os.getcwd(), os.pardir) if os.path.basename(os.getcwd()) == "tools" else os.getcwd()
|
||||||
|
|
||||||
for library in libraries:
|
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:
|
try:
|
||||||
os.rename(
|
os.rename(src, dst)
|
||||||
os.path.join(path, "Library", library), os.path.join(dest_dir, library)
|
|
||||||
)
|
|
||||||
except OSError:
|
except OSError:
|
||||||
shutil.rmtree(os.path.join(dest_dir, library))
|
if os.path.exists(dst):
|
||||||
os.rename(
|
shutil.rmtree(dst)
|
||||||
os.path.join(path, "Library", library), os.path.join(dest_dir, library)
|
os.rename(src, dst)
|
||||||
)
|
|
||||||
try:
|
license_path = os.path.join(path, "License.txt")
|
||||||
os.rename(
|
dst_license = os.path.join(dest_dir, "TTSDK_license.txt")
|
||||||
os.path.join(path, "License.txt"), os.path.join(dest_dir, "TTSDK_license.txt")
|
|
||||||
)
|
if os.path.exists(license_path):
|
||||||
except FileExistsError:
|
if os.path.exists(dst_license):
|
||||||
os.remove(os.path.join(dest_dir, "TTSDK_license.txt"))
|
os.remove(dst_license)
|
||||||
os.rename(
|
os.rename(license_path, dst_license)
|
||||||
os.path.join(path, "License.txt"), os.path.join(dest_dir, "TTSDK_license.txt")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def clean() -> None:
|
def clean() -> None:
|
||||||
@ -100,17 +114,17 @@ def clean() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def install() -> None:
|
def install() -> None:
|
||||||
print("Installing TeamTalk sdk components")
|
print("Starting TeamTalk SDK installation...")
|
||||||
print("Downloading latest sdk version")
|
print("Downloading the latest SDK version...")
|
||||||
download()
|
download()
|
||||||
print("Downloaded. extracting")
|
print("Download complete. Extracting...")
|
||||||
extract()
|
extract()
|
||||||
print("Extracted. moving")
|
print("Extraction complete. Moving files...")
|
||||||
move()
|
move()
|
||||||
print("moved. cleaning")
|
print("Move complete. Cleaning up...")
|
||||||
clean()
|
clean()
|
||||||
print("cleaned.")
|
print("Cleanup done.")
|
||||||
print("Installed")
|
print("TeamTalk SDK successfully installed.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user