mirror of
https://github.com/Threnklyn/nton.git
synced 2026-05-18 21:03:28 +02:00
Warn if the NRO has no icon instead of crashing
This commit is contained in:
+23
-18
@@ -264,25 +264,30 @@ def build(
|
|||||||
else:
|
else:
|
||||||
icon_file_res = nstool.get_icon(path, icon_file)
|
icon_file_res = nstool.get_icon(path, icon_file)
|
||||||
if icon_file_res:
|
if icon_file_res:
|
||||||
log.critical(f"Failed extracting the Icon partition from the NRO, {icon_file_res}")
|
if icon_file_res == "No Icon was extracted from the asset.":
|
||||||
sys.exit(2)
|
log.warning("The NRO does not have an Icon, proceeding without one.")
|
||||||
log.debug("Got the Icon partition")
|
else:
|
||||||
log.debug(base64.b64encode(icon_file.read_bytes()).decode())
|
log.critical(f"Failed extracting the Icon partition from the NRO, {icon_file_res}")
|
||||||
|
sys.exit(2)
|
||||||
|
else:
|
||||||
|
log.debug("Got the Icon partition")
|
||||||
|
log.debug(base64.b64encode(icon_file.read_bytes()).decode())
|
||||||
|
|
||||||
# We must strip every unnecessary metadata or the icon will be a '?'
|
if icon_file.exists():
|
||||||
try:
|
# We must strip every unnecessary metadata or the icon will be a '?'
|
||||||
subprocess.check_output([
|
try:
|
||||||
Binaries.magick, "mogrify",
|
subprocess.check_output([
|
||||||
"-format", "jpg",
|
Binaries.magick, "mogrify",
|
||||||
"-resize", "256x256",
|
"-format", "jpg",
|
||||||
"-strip", str(icon_file.absolute())
|
"-resize", "256x256",
|
||||||
])
|
"-strip", str(icon_file.absolute())
|
||||||
# magick changes the .dat to .jpg, let's undo that
|
])
|
||||||
icon_file.unlink()
|
# magick changes the .dat to .jpg, let's undo that
|
||||||
shutil.move(icon_file.with_suffix(".jpg"), icon_file)
|
icon_file.unlink()
|
||||||
except subprocess.CalledProcessError as e:
|
shutil.move(icon_file.with_suffix(".jpg"), icon_file)
|
||||||
log.critical(f"Failed to convert and strip the Icon, {e.output} [{e.returncode}]")
|
except subprocess.CalledProcessError as e:
|
||||||
sys.exit(2)
|
log.critical(f"Failed to convert and strip the Icon, {e.output} [{e.returncode}]")
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
next_nro_path = sdmc
|
next_nro_path = sdmc
|
||||||
next_nro_path_file.write_text(next_nro_path)
|
next_nro_path_file.write_text(next_nro_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user