diff options
author | David McMackins II <contact@mcmackins.org> | 2016-05-28 12:27:39 -0500 |
---|---|---|
committer | David McMackins II <contact@mcmackins.org> | 2016-05-28 12:27:39 -0500 |
commit | c9818ebdd685dc6e7f9f30e577f31a63a8180cae (patch) | |
tree | dd9355f2396ed6b33dd19729dcf70e7d427bc454 | |
parent | ce7dad2e80ab21870aecbde0ac95acc7732355d6 (diff) |
Fix fail procedure
-rw-r--r-- | gbromgen.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/gbromgen.py b/gbromgen.py index b4d683a..bd56a5b 100644 --- a/gbromgen.py +++ b/gbromgen.py @@ -123,18 +123,13 @@ def get_mbc_type(mbc_str): return VALID_CART_TYPES['+'.join(specs)] def warn(*args): - print(__title__ + ': warning:', *args, file=stderr) + print(__title__ + ': warning: ', *args, file=stderr) -def clean_gb(): - try: - if exists(gb_path): - remove(gb_path) - except NameError: - pass +def fail(*args, rm=None): + if rm and exists(rm): + remove(rm) -def fail(*args): - clean_gb() - exit(__title__ + ': error:', *args, file=stderr) + exit(__title__ + ': error: ' + ' '.join(args)) def print_bank_info(n, written, verbose=False): if verbose: @@ -304,7 +299,7 @@ def main(args=argv[1:]): if mbc == 0x00: if size > ROMBANK_SIZE * 2: - fail('ROM size exceeds 32k') + fail('ROM size exceeds 32k', rm=gb_path) if size < ROMBANK_SIZE: flush_bank(outfile, size) @@ -315,7 +310,7 @@ def main(args=argv[1:]): exit(0) if size > ROMBANK_SIZE: - fail('Game code exceeds space in ROM bank 0') + fail('Game code exceeds space in ROM bank 0', rm=gb_path) flush_bank(outfile, size) @@ -324,7 +319,8 @@ def main(args=argv[1:]): write_bank(banks_written, outfile, args.verbose) banks_written += 1 except Exception as e: - clean_gb() + if exists(gb_path): + remove(gb_path) raise finally: rmtree(TEMPDIR) |