mirror of
https://github.com/NinjaCheetah/WiiPy.git
synced 2026-02-17 02:25:39 -05:00
Rewrote error output to be much clearer, no longer raises Python exceptions
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
import pathlib
|
||||
import libWiiPy
|
||||
from modules.core import fatal_error
|
||||
|
||||
|
||||
def handle_emunand_title(args):
|
||||
@@ -17,12 +18,12 @@ def handle_emunand_title(args):
|
||||
input_path = pathlib.Path(args.install)
|
||||
|
||||
if not input_path.exists():
|
||||
raise FileNotFoundError(input_path)
|
||||
fatal_error("The specified WAD file does not exist!")
|
||||
|
||||
if input_path.is_dir():
|
||||
wad_files = list(input_path.glob("*.[wW][aA][dD]"))
|
||||
if not wad_files:
|
||||
raise FileNotFoundError("No WAD files were found in the provided input directory!")
|
||||
fatal_error("No WAD files were found in the provided input directory!")
|
||||
wad_count = 0
|
||||
for wad in wad_files:
|
||||
title = libWiiPy.title.Title()
|
||||
@@ -50,7 +51,7 @@ def handle_emunand_title(args):
|
||||
target_tid = input_str
|
||||
|
||||
if len(target_tid) != 16:
|
||||
raise ValueError("Invalid Title ID! Title IDs must be 16 characters long.")
|
||||
fatal_error("The provided Title ID is invalid! Title IDs must be 16 characters long.")
|
||||
|
||||
emunand.uninstall_title(target_tid)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import pathlib
|
||||
import libWiiPy
|
||||
from modules.core import fatal_error
|
||||
|
||||
|
||||
def handle_setting_decrypt(args):
|
||||
@@ -13,7 +14,7 @@ def handle_setting_decrypt(args):
|
||||
output_path = pathlib.Path(input_path.stem + "_dec" + input_path.suffix)
|
||||
|
||||
if not input_path.exists():
|
||||
raise FileNotFoundError(input_path)
|
||||
fatal_error("The specified setting file does not exist!")
|
||||
|
||||
# Load and decrypt the provided file.
|
||||
setting = libWiiPy.nand.SettingTxt()
|
||||
@@ -31,7 +32,7 @@ def handle_setting_encrypt(args):
|
||||
output_path = pathlib.Path("setting.txt")
|
||||
|
||||
if not input_path.exists():
|
||||
raise FileNotFoundError(input_path)
|
||||
fatal_error("The specified setting file does not exist!")
|
||||
|
||||
# Load and encrypt the provided file.
|
||||
setting = libWiiPy.nand.SettingTxt()
|
||||
@@ -44,11 +45,11 @@ def handle_setting_encrypt(args):
|
||||
def handle_setting_gen(args):
|
||||
# Validate the provided SN. It should be 2 or 3 letters followed by 9 numbers.
|
||||
if len(args.serno) != 11 and len(args.serno) != 12:
|
||||
raise ValueError("The provided Serial Number is not valid!")
|
||||
fatal_error("The provided Serial Number is not valid!")
|
||||
try:
|
||||
int(args.serno[-9:])
|
||||
except ValueError:
|
||||
raise ValueError("The provided Serial Number is not valid!")
|
||||
fatal_error("The provided Serial Number is not valid!")
|
||||
prefix = args.serno[:-9]
|
||||
# Detect the console revision based on the SN.
|
||||
match prefix[0].upper():
|
||||
@@ -64,11 +65,13 @@ def handle_setting_gen(args):
|
||||
# of 11 characters, while other regions have a three-letter prefix for a total length of 12 characters.
|
||||
valid_regions = ["USA", "EUR", "JPN", "KOR"]
|
||||
if args.region not in valid_regions:
|
||||
raise ValueError("The provided region is not valid!")
|
||||
fatal_error(f"The provided region \"{args.region}\" is not valid!")
|
||||
if len(prefix) == 2 and args.region != "USA":
|
||||
raise ValueError("The provided region does not match the provided Serial Number!")
|
||||
fatal_error(f"The provided region \"{args.region}\" does not match the provided Serial Number "
|
||||
f"\"{args.serno}\"!\"")
|
||||
elif len(prefix) == 3 and args.region == "USA":
|
||||
raise ValueError("The provided region does not match the provided Serial Number!")
|
||||
fatal_error(f"The provided region \"{args.region}\" does not match the provided Serial Number "
|
||||
f"\"{args.serno}\"!\"")
|
||||
# Get the values for VIDEO and GAME.
|
||||
video = ""
|
||||
game = ""
|
||||
|
||||
Reference in New Issue
Block a user