Inform user when enemizer returns non-zero exit code, log the error content

This commit is contained in:
cassidoxa
2020-12-29 14:59:22 -05:00
parent 2a05e94970
commit d6d19158a7

25
Rom.py
View File

@@ -284,14 +284,23 @@ def patch_enemizer(world, player, rom, baserom_path, enemizercli, random_sprite_
with open(options_path, 'w') as f: with open(options_path, 'w') as f:
json.dump(options, f) json.dump(options, f)
subprocess.check_call([os.path.abspath(enemizercli), try:
'--rom', baserom_path, subprocess.run([os.path.abspath(enemizercli),
'--seed', str(world.rom_seeds[player]), '--rom', baserom_path,
'--base', basepatch_path, '--seed', str(world.rom_seeds[player]),
'--randomizer', randopatch_path, '--base', basepatch_path,
'--enemizer', options_path, '--randomizer', randopatch_path,
'--output', enemizer_output_path], '--enemizer', options_path,
cwd=os.path.dirname(enemizercli), stdout=subprocess.DEVNULL) '--output', enemizer_output_path],
cwd=os.path.dirname(enemizercli),
check=True,
capture_output=True)
except subprocess.CalledProcessError as e:
from Main import EnemizerError
enemizerMsg = world.fish.translate("cli","cli","Enemizer returned exit code: ") + str(e.returncode) + "\n"
enemizerMsg += world.fish.translate("cli","cli","enemizer.nothing.applied")
logging.error(f'Enemizer error output: {e.stderr.decode("utf-8")}\n')
raise EnemizerError(enemizerMsg)
with open(enemizer_basepatch_path, 'r') as f: with open(enemizer_basepatch_path, 'r') as f:
for patch in json.load(f): for patch in json.load(f):