Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit 0e4fa90

Browse files
committed
🐛 Fix alpha or beta version installation and logs saving to ..
Fixes #63 Fixes #79
1 parent f70908a commit 0e4fa90

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

vanilla_installer/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
logger = logging.getLogger()
99
logger.setLevel(logging.DEBUG)
10-
logfile_path = str(pathlib.Path("../logs").resolve() / "vanilla_installer.log")
10+
logfile_path = str(pathlib.Path("./logs").resolve() / "vanilla_installer.log")
1111
try:
1212
handler = logging.handlers.RotatingFileHandler(
1313
filename=logfile_path,

vanilla_installer/main.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import subprocess
1515
import zipfile
1616
from pathlib import Path
17-
from typing import Optional
17+
from typing import Optional, Tuple
1818

1919
import click
2020
import minecraft_launcher_lib as mll
@@ -253,20 +253,20 @@ def install_fabric(mc_version: str, mc_dir: str) -> str:
253253
str: The Fabric version id. Formatted as `fabric-loader-{fabric_version}-{game_version}`.
254254
"""
255255
meta_placeholder = "https://meta.fabricmc.net/v2/versions/loader/{}/{}/profile/zip"
256-
pack_toml_url = f"https://raw.githubusercontent.com/Fabulously-Optimized/Fabulously-Optimized/main/Packwiz/{mc_version}/pack.toml"
256+
pack_toml_url = convert_version(mc_version)
257257

258-
if (response := requests.get(pack_toml_url)).status_code == 200:
258+
# if (response := requests.get(pack_toml_url)).status_code == 200:
259+
response = requests.get(pack_toml_url)
260+
pack_info = toml.parse(response.text)
261+
game_version = pack_info["versions"]["minecraft"]
262+
fabric_version = pack_info["versions"]["fabric"]
263+
meta_url = meta_placeholder.format(game_version, fabric_version)
259264

260-
pack_info: dict = toml.loads(response.text)
261-
game_version = pack_info.get("versions", {}).get("minecraft")
262-
fabric_version = pack_info.get("versions", {}).get("fabric")
263-
meta_url = meta_placeholder.format(game_version, fabric_version)
264-
265-
if (response := requests.get(meta_url)).status_code == 200:
266-
with zipfile.ZipFile(io.BytesIO(response.content)) as archive:
267-
version_id = f"fabric-loader-{fabric_version}-{game_version}"
268-
path = str(Path(mc_dir).resolve() / "versions")
269-
archive.extractall(path)
265+
response = requests.get(meta_url)
266+
version_id = f"fabric-loader-{fabric_version}-{game_version}"
267+
with zipfile.ZipFile(io.BytesIO(response.content)) as archive:
268+
path = str(Path(mc_dir).resolve() / "versions")
269+
archive.extractall(path)
270270

271271
return version_id
272272

@@ -312,7 +312,7 @@ def install_pack(
312312
logger.debug("Installing the pack now.")
313313
os.chdir(mc_dir)
314314
os.makedirs(f"{get_dir()}/", exist_ok=True)
315-
pack_toml = f"https://raw.githubusercontent.com/Fabulously-Optimized/Fabulously-Optimized/main/Packwiz/{mc_version}/pack.toml"
315+
pack_toml = convert_version(mc_version)
316316
try:
317317
ran = command(
318318
f"{get_java(java_ver)} -jar {packwiz_installer_bootstrap} {pack_toml}"
@@ -380,7 +380,10 @@ def get_pack_mc_versions() -> dict:
380380
# In this case, fall back to a local file since in the latter you'll likely have the whole repo cloned.
381381
# For this to work, you need to be in the root directory of the repository running this, otherwise the files will not be found.
382382
logger.warning("GitHub failed, falling back to local...")
383-
local_path = Path("vanilla_installer/assets").resolve() / "versions.json"
383+
try:
384+
local_path = Path("vanilla_installer/assets").resolve() / "versions.json"
385+
except:
386+
local_path = Path("assets").resolve() / "versions.json"
384387
response = json.loads(local_path.read_bytes())
385388

386389
return_value = dict(response)

0 commit comments

Comments
 (0)