Compare commits

..

No commits in common. "master" and "1.0.0" have entirely different histories.

6 changed files with 173 additions and 163 deletions

View File

@ -1,2 +0,0 @@
python -m pip install -r requirements.txt
python -m pip install -r build-requirements-nuitka.txt

View File

@ -1,3 +1,3 @@
nuitka==1.4.8 nuitka==1.2.4
ordered-set==4.1.0 ordered-set==4.1.0
zstandard==0.20.0 zstandard==0.19.0

View File

@ -0,0 +1 @@
pyinstaller==5.7.0

View File

@ -1 +0,0 @@
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

View File

@ -1,157 +1,125 @@
from functools import total_ordering import os
import os import pathlib
import pathlib import re
import re import sys
import sys import winreg
import winreg import zipfile
import zipfile
from bs4 import BeautifulSoup as Soup
from bs4 import BeautifulSoup as Soup import requests
import requests
SKU_URL = "https://duugu.github.io/Sku"
SKU_URL = "https://duugu.github.io/Sku"
def confirmed_exit(code: int):
@total_ordering print("Press enter to exit program")
class Version: input()
major: int sys.exit(code)
minor: int
def __init__(self, number: float):
components = str(number).split(".") def find_wowc() -> str:
self.major = int(components[0]) key = winreg.OpenKey(
self.minor = int(components[1]) if len(components) > 1 else 0 winreg.HKEY_LOCAL_MACHINE,
r"SOFTWARE\WOW6432Node\Blizzard Entertainment\World of Warcraft",
def __eq__(self, other) -> bool: )
return self.major == other.major and self.minor == other.minor value = winreg.QueryValueEx(key, "InstallPath")
return value[0]
def __lt__(self, other) -> bool:
if self.major != other.major:
return self.major < other.major def get_sku_version(sku_path: pathlib.Path) -> float:
else: changelog_path = sku_path / "CHANGELOG.md"
return self.minor < other.minor with changelog_path.open("r") as f:
txt = f.read()
def __gt__(self, other) -> bool: version_match = re.search(r"^\# Sku \((\d+\.\d+)\)", txt)
if self.major != other.major: if not version_match:
return self.major > other.major print("Unable to determine Sku version")
else: confirmed_exit(1)
return self.minor > other.minor try:
version = float(version_match.group(1))
def __str__(self) -> str: except ValueError:
return f"{self.major}.{self.minor}" print("Unable to determine Sku version")
confirmed_exit(1)
def __repr__(self): return version
return str(self)
def fetch_sku_version() -> tuple[float, str]:
def confirmed_exit(code: int): rre = re.compile(
print("Press enter to exit program") r"^https://github.com/Duugu/Sku/releases/download/r\d+\.\d+/Sku-r\d+\.\d+-.+\.zip$",
input() re.I,
sys.exit(code) )
r = requests.get(SKU_URL)
page = Soup(r.text, features="html.parser")
def find_wowc() -> str: links = page.findAll("a", attrs={"href": rre})
key = winreg.OpenKey( if len(links) < 1:
winreg.HKEY_LOCAL_MACHINE, print("Unable to fetch latest Sku version info")
r"SOFTWARE\WOW6432Node\Blizzard Entertainment\World of Warcraft", confirmed_exit(1)
) href = links[0].get("href")
value = winreg.QueryValueEx(key, "InstallPath") version_match = re.search(
return value[0] r"^https://github.com/Duugu/Sku/releases/download/r\d+\.\d+/Sku-r(\d+\.\d+)-.+\.zip$",
href,
)
def get_sku_version(sku_path: pathlib.Path) -> float: if not version_match:
changelog_path = sku_path / "CHANGELOG.md" print("Unable to fetch latest Sku version")
with changelog_path.open("r") as f: confirmed_exit(1)
txt = f.read() version = float(version_match.group(1))
version_match = re.search(r"^\# Sku \(((\d+\.\d+)|(\d+))\)", txt) return (version, href)
if not version_match:
print("Unable to determine Sku version")
confirmed_exit(1) def update_sku(sku_info: tuple[float, str], sku_path: pathlib.Path):
try: url = sku_info[1]
version = float(version_match.group(1)) local_filename = url.split("/")[-1]
except ValueError: print("Downloading... ")
print("Unable to determine Sku version") with requests.get(url, stream=True) as r:
confirmed_exit(1) r.raise_for_status()
return Version(version) with open(local_filename, "wb") as f:
for chunk in r.iter_content(4096):
f.write(chunk)
def fetch_sku_version() -> tuple[float, str]: print("Installing...")
rre = re.compile( with zipfile.ZipFile(local_filename, "r") as zf:
r"^https://github.com/Duugu/Sku/releases/download/r(\d+\.\d+)|(\d+)/Sku-r(\d+\.\d+)|(\d+)-.+\.zip$", zf.extractall(str(sku_path.parent.resolve()))
re.I, print("Cleaning...")
) os.remove(local_filename)
r = requests.get(SKU_URL)
page = Soup(r.text, features="html.parser")
links = page.findAll("a", attrs={"href": rre}) def main():
if len(links) < 1: print("Searching World of Warcraft Classic installation...")
print("Unable to fetch latest Sku version info") try:
confirmed_exit(1) wowc_path = find_wowc()
href = links[0].get("href") except FileNotFoundError:
version_match = re.search( print("Unable to find World of Warcraft Classic installation.")
r"^https://github.com/Duugu/Sku/releases/download/r(\d+\.\d+)|(\d+)/Sku-r((\d+\.\d+)|(\d+))-.+\.zip$", confirmed_exit(1)
href, print(f"Found WoW Classic at path {wowc_path}")
) sku_path = pathlib.Path(wowc_path) / "Interface" / "AddOns" / "Sku"
if not version_match: if not sku_path.exists():
print("Unable to fetch latest Sku version") print("Couldn't find Sku folder. Check your installation")
confirmed_exit(1) confirmed_exit(1)
version = float(version_match.group(1)) print(f"Found Sku at path {str(sku_path)}")
return (Version(version), href) sku_version = get_sku_version(sku_path)
print(f"Current Sku version is {sku_version}")
print("Checking for updates...")
def update_sku(sku_info: tuple[float, str], sku_path: pathlib.Path): info = fetch_sku_version()
url = sku_info[1] print(f"Latest available Sku version is {info[0]}")
local_filename = url.split("/")[-1] if info[0] <= sku_version:
print("Downloading... ") print("Your version of Sku is equal or newer than latest available. Exiting...")
with requests.get(url, stream=True) as r: confirmed_exit(0)
r.raise_for_status() answer = input(
with open(local_filename, "wb") as f: "Do you want to update to the latest version? y - yes, n or other letter - no: "
for chunk in r.iter_content(4096): )
f.write(chunk) if answer != "y":
print("Installing...") print("Ok, not updating.")
with zipfile.ZipFile(local_filename, "r") as zf: confirmed_exit(0)
zf.extractall(str(sku_path.parent.resolve())) print("Updating...")
print("Cleaning...") update_sku(info, sku_path)
os.remove(local_filename) print("Verifying update...")
new_version = get_sku_version(sku_path)
if sku_version == new_version:
def main(): print("Verification failed!")
print("Searching World of Warcraft Classic installation...") confirmed_exit(1)
try: print("Update complete!")
wowc_path = find_wowc() print(f"Sku updated from {sku_version} to {new_version}")
except FileNotFoundError: confirmed_exit(0)
print("Unable to find World of Warcraft Classic installation.")
confirmed_exit(1)
print(f"Found WoW Classic at path {wowc_path}") if __name__ == "__main__":
sku_path = pathlib.Path(wowc_path) / "Interface" / "AddOns" / "Sku" main()
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()

44
sku-updater.spec Normal file
View File

@ -0,0 +1,44 @@
# -*- 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,
)