Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f947553ac9 | ||
|
|
7202e37bcb | ||
|
|
2d6625c52a |
2
bootstrap.cmd
Normal file
2
bootstrap.cmd
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
python -m pip install -r requirements.txt
|
||||||
|
python -m pip install -r build-requirements-nuitka.txt
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
nuitka==1.2.4
|
nuitka==1.4.8
|
||||||
ordered-set==4.1.0
|
ordered-set==4.1.0
|
||||||
zstandard==0.19.0
|
zstandard==0.20.0
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
pyinstaller==5.7.0
|
|
||||||
1
build.cmd
Normal file
1
build.cmd
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
python -m nuitka --standalone --onefile --prefer-source-code --assume-yes-for-downloads --remove-output --lto=yes --windows-uac-admin --company-name=Cyrmax --product-name=Sku_Updater --file-version=32.15 --product-version=32.15 --file-description="A console program to update your installation of Sku for WoW Classic" --copyright="Made by Cyrmax in 2022. MIT license" sku-updater.py
|
||||||
282
sku-updater.py
282
sku-updater.py
|
|
@ -1,125 +1,157 @@
|
||||||
import os
|
from functools import total_ordering
|
||||||
import pathlib
|
import os
|
||||||
import re
|
import pathlib
|
||||||
import sys
|
import re
|
||||||
import winreg
|
import sys
|
||||||
import zipfile
|
import winreg
|
||||||
|
import zipfile
|
||||||
from bs4 import BeautifulSoup as Soup
|
|
||||||
import requests
|
from bs4 import BeautifulSoup as Soup
|
||||||
|
import requests
|
||||||
|
|
||||||
SKU_URL = "https://duugu.github.io/Sku"
|
|
||||||
|
SKU_URL = "https://duugu.github.io/Sku"
|
||||||
|
|
||||||
def confirmed_exit(code: int):
|
|
||||||
print("Press enter to exit program")
|
@total_ordering
|
||||||
input()
|
class Version:
|
||||||
sys.exit(code)
|
major: int
|
||||||
|
minor: int
|
||||||
|
def __init__(self, number: float):
|
||||||
def find_wowc() -> str:
|
components = str(number).split(".")
|
||||||
key = winreg.OpenKey(
|
self.major = int(components[0])
|
||||||
winreg.HKEY_LOCAL_MACHINE,
|
self.minor = int(components[1]) if len(components) > 1 else 0
|
||||||
r"SOFTWARE\WOW6432Node\Blizzard Entertainment\World of Warcraft",
|
|
||||||
)
|
def __eq__(self, other) -> bool:
|
||||||
value = winreg.QueryValueEx(key, "InstallPath")
|
return self.major == other.major and self.minor == other.minor
|
||||||
return value[0]
|
|
||||||
|
def __lt__(self, other) -> bool:
|
||||||
|
if self.major != other.major:
|
||||||
def get_sku_version(sku_path: pathlib.Path) -> float:
|
return self.major < other.major
|
||||||
changelog_path = sku_path / "CHANGELOG.md"
|
else:
|
||||||
with changelog_path.open("r") as f:
|
return self.minor < other.minor
|
||||||
txt = f.read()
|
|
||||||
version_match = re.search(r"^\# Sku \((\d+\.\d+)\)", txt)
|
def __gt__(self, other) -> bool:
|
||||||
if not version_match:
|
if self.major != other.major:
|
||||||
print("Unable to determine Sku version")
|
return self.major > other.major
|
||||||
confirmed_exit(1)
|
else:
|
||||||
try:
|
return self.minor > other.minor
|
||||||
version = float(version_match.group(1))
|
|
||||||
except ValueError:
|
def __str__(self) -> str:
|
||||||
print("Unable to determine Sku version")
|
return f"{self.major}.{self.minor}"
|
||||||
confirmed_exit(1)
|
|
||||||
return version
|
def __repr__(self):
|
||||||
|
return str(self)
|
||||||
|
|
||||||
def fetch_sku_version() -> tuple[float, str]:
|
|
||||||
rre = re.compile(
|
def confirmed_exit(code: int):
|
||||||
r"^https://github.com/Duugu/Sku/releases/download/r\d+\.\d+/Sku-r\d+\.\d+-.+\.zip$",
|
print("Press enter to exit program")
|
||||||
re.I,
|
input()
|
||||||
)
|
sys.exit(code)
|
||||||
r = requests.get(SKU_URL)
|
|
||||||
page = Soup(r.text, features="html.parser")
|
|
||||||
links = page.findAll("a", attrs={"href": rre})
|
def find_wowc() -> str:
|
||||||
if len(links) < 1:
|
key = winreg.OpenKey(
|
||||||
print("Unable to fetch latest Sku version info")
|
winreg.HKEY_LOCAL_MACHINE,
|
||||||
confirmed_exit(1)
|
r"SOFTWARE\WOW6432Node\Blizzard Entertainment\World of Warcraft",
|
||||||
href = links[0].get("href")
|
)
|
||||||
version_match = re.search(
|
value = winreg.QueryValueEx(key, "InstallPath")
|
||||||
r"^https://github.com/Duugu/Sku/releases/download/r\d+\.\d+/Sku-r(\d+\.\d+)-.+\.zip$",
|
return value[0]
|
||||||
href,
|
|
||||||
)
|
|
||||||
if not version_match:
|
def get_sku_version(sku_path: pathlib.Path) -> float:
|
||||||
print("Unable to fetch latest Sku version")
|
changelog_path = sku_path / "CHANGELOG.md"
|
||||||
confirmed_exit(1)
|
with changelog_path.open("r") as f:
|
||||||
version = float(version_match.group(1))
|
txt = f.read()
|
||||||
return (version, href)
|
version_match = re.search(r"^\# Sku \(((\d+\.\d+)|(\d+))\)", txt)
|
||||||
|
if not version_match:
|
||||||
|
print("Unable to determine Sku version")
|
||||||
def update_sku(sku_info: tuple[float, str], sku_path: pathlib.Path):
|
confirmed_exit(1)
|
||||||
url = sku_info[1]
|
try:
|
||||||
local_filename = url.split("/")[-1]
|
version = float(version_match.group(1))
|
||||||
print("Downloading... ")
|
except ValueError:
|
||||||
with requests.get(url, stream=True) as r:
|
print("Unable to determine Sku version")
|
||||||
r.raise_for_status()
|
confirmed_exit(1)
|
||||||
with open(local_filename, "wb") as f:
|
return Version(version)
|
||||||
for chunk in r.iter_content(4096):
|
|
||||||
f.write(chunk)
|
|
||||||
print("Installing...")
|
def fetch_sku_version() -> tuple[float, str]:
|
||||||
with zipfile.ZipFile(local_filename, "r") as zf:
|
rre = re.compile(
|
||||||
zf.extractall(str(sku_path.parent.resolve()))
|
r"^https://github.com/Duugu/Sku/releases/download/r(\d+\.\d+)|(\d+)/Sku-r(\d+\.\d+)|(\d+)-.+\.zip$",
|
||||||
print("Cleaning...")
|
re.I,
|
||||||
os.remove(local_filename)
|
)
|
||||||
|
r = requests.get(SKU_URL)
|
||||||
|
page = Soup(r.text, features="html.parser")
|
||||||
def main():
|
links = page.findAll("a", attrs={"href": rre})
|
||||||
print("Searching World of Warcraft Classic installation...")
|
if len(links) < 1:
|
||||||
try:
|
print("Unable to fetch latest Sku version info")
|
||||||
wowc_path = find_wowc()
|
confirmed_exit(1)
|
||||||
except FileNotFoundError:
|
href = links[0].get("href")
|
||||||
print("Unable to find World of Warcraft Classic installation.")
|
version_match = re.search(
|
||||||
confirmed_exit(1)
|
r"^https://github.com/Duugu/Sku/releases/download/r(\d+\.\d+)|(\d+)/Sku-r((\d+\.\d+)|(\d+))-.+\.zip$",
|
||||||
print(f"Found WoW Classic at path {wowc_path}")
|
href,
|
||||||
sku_path = pathlib.Path(wowc_path) / "Interface" / "AddOns" / "Sku"
|
)
|
||||||
if not sku_path.exists():
|
if not version_match:
|
||||||
print("Couldn't find Sku folder. Check your installation")
|
print("Unable to fetch latest Sku version")
|
||||||
confirmed_exit(1)
|
confirmed_exit(1)
|
||||||
print(f"Found Sku at path {str(sku_path)}")
|
version = float(version_match.group(1))
|
||||||
sku_version = get_sku_version(sku_path)
|
return (Version(version), href)
|
||||||
print(f"Current Sku version is {sku_version}")
|
|
||||||
print("Checking for updates...")
|
|
||||||
info = fetch_sku_version()
|
def update_sku(sku_info: tuple[float, str], sku_path: pathlib.Path):
|
||||||
print(f"Latest available Sku version is {info[0]}")
|
url = sku_info[1]
|
||||||
if info[0] <= sku_version:
|
local_filename = url.split("/")[-1]
|
||||||
print("Your version of Sku is equal or newer than latest available. Exiting...")
|
print("Downloading... ")
|
||||||
confirmed_exit(0)
|
with requests.get(url, stream=True) as r:
|
||||||
answer = input(
|
r.raise_for_status()
|
||||||
"Do you want to update to the latest version? y - yes, n or other letter - no: "
|
with open(local_filename, "wb") as f:
|
||||||
)
|
for chunk in r.iter_content(4096):
|
||||||
if answer != "y":
|
f.write(chunk)
|
||||||
print("Ok, not updating.")
|
print("Installing...")
|
||||||
confirmed_exit(0)
|
with zipfile.ZipFile(local_filename, "r") as zf:
|
||||||
print("Updating...")
|
zf.extractall(str(sku_path.parent.resolve()))
|
||||||
update_sku(info, sku_path)
|
print("Cleaning...")
|
||||||
print("Verifying update...")
|
os.remove(local_filename)
|
||||||
new_version = get_sku_version(sku_path)
|
|
||||||
if sku_version == new_version:
|
|
||||||
print("Verification failed!")
|
def main():
|
||||||
confirmed_exit(1)
|
print("Searching World of Warcraft Classic installation...")
|
||||||
print("Update complete!")
|
try:
|
||||||
print(f"Sku updated from {sku_version} to {new_version}")
|
wowc_path = find_wowc()
|
||||||
confirmed_exit(0)
|
except FileNotFoundError:
|
||||||
|
print("Unable to find World of Warcraft Classic installation.")
|
||||||
|
confirmed_exit(1)
|
||||||
if __name__ == "__main__":
|
print(f"Found WoW Classic at path {wowc_path}")
|
||||||
main()
|
sku_path = pathlib.Path(wowc_path) / "Interface" / "AddOns" / "Sku"
|
||||||
|
if not sku_path.exists():
|
||||||
|
print("Couldn't find Sku folder. Check your installation")
|
||||||
|
confirmed_exit(1)
|
||||||
|
print(f"Found Sku at path {str(sku_path)}")
|
||||||
|
sku_version = get_sku_version(sku_path)
|
||||||
|
print(f"Current Sku version is {sku_version}")
|
||||||
|
print("Checking for updates...")
|
||||||
|
info = fetch_sku_version()
|
||||||
|
print(f"Latest available Sku version is {info[0]}")
|
||||||
|
if info[0] <= sku_version:
|
||||||
|
print("Your version of Sku is equal or newer than latest available. Exiting...")
|
||||||
|
confirmed_exit(0)
|
||||||
|
answer = input(
|
||||||
|
"Do you want to update to the latest version? y - yes, n or other letter - no: "
|
||||||
|
)
|
||||||
|
if answer != "y":
|
||||||
|
print("Ok, not updating.")
|
||||||
|
confirmed_exit(0)
|
||||||
|
print("Updating...")
|
||||||
|
update_sku(info, sku_path)
|
||||||
|
print("Verifying update...")
|
||||||
|
new_version = get_sku_version(sku_path)
|
||||||
|
if sku_version == new_version:
|
||||||
|
print("Verification failed!")
|
||||||
|
confirmed_exit(1)
|
||||||
|
print("Update complete!")
|
||||||
|
print(f"Sku updated from {sku_version} to {new_version}")
|
||||||
|
confirmed_exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
# -*- mode: python ; coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
block_cipher = None
|
|
||||||
|
|
||||||
|
|
||||||
a = Analysis(
|
|
||||||
['sku-updater.py'],
|
|
||||||
pathex=[],
|
|
||||||
binaries=[],
|
|
||||||
datas=[],
|
|
||||||
hiddenimports=[],
|
|
||||||
hookspath=[],
|
|
||||||
hooksconfig={},
|
|
||||||
runtime_hooks=[],
|
|
||||||
excludes=[],
|
|
||||||
win_no_prefer_redirects=False,
|
|
||||||
win_private_assemblies=False,
|
|
||||||
cipher=block_cipher,
|
|
||||||
noarchive=False,
|
|
||||||
)
|
|
||||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
|
||||||
|
|
||||||
exe = EXE(
|
|
||||||
pyz,
|
|
||||||
a.scripts,
|
|
||||||
a.binaries,
|
|
||||||
a.zipfiles,
|
|
||||||
a.datas,
|
|
||||||
[],
|
|
||||||
name='sku-updater',
|
|
||||||
debug=False,
|
|
||||||
bootloader_ignore_signals=False,
|
|
||||||
strip=False,
|
|
||||||
upx=True,
|
|
||||||
upx_exclude=[],
|
|
||||||
runtime_tmpdir=None,
|
|
||||||
console=True,
|
|
||||||
disable_windowed_traceback=False,
|
|
||||||
argv_emulation=False,
|
|
||||||
target_arch=None,
|
|
||||||
codesign_identity=None,
|
|
||||||
entitlements_file=None,
|
|
||||||
)
|
|
||||||
Loading…
Reference in New Issue
Block a user