diff options
author | Pedro de Medeiros <pedro.medeiros@gmail.com> | 2021-06-02 22:31:12 -0300 |
---|---|---|
committer | Pedro de Medeiros <pedro.medeiros@gmail.com> | 2021-06-02 22:31:12 -0300 |
commit | 69b4102c996f1793dbc7280924ae023281f94d30 (patch) | |
tree | 6613ff9dca3e8380cf222c566601d7a6991301de /tools | |
parent | 61bc09a25e83193c68057341bfb33150785b4bcd (diff) | |
download | ubox-msx-lib-69b4102c996f1793dbc7280924ae023281f94d30.tar.gz ubox-msx-lib-69b4102c996f1793dbc7280924ae023281f94d30.zip |
map.py: remove generated files on error
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/map.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/map.py b/tools/map.py index c2e2212..53c98b7 100755 --- a/tools/map.py +++ b/tools/map.py @@ -318,6 +318,7 @@ def main(): if args.bin: for i, block in enumerate(out): filename = path.join(args.dir, "%s%02d.bin" % (args.id, i)) + remove_list.append(filename) with open(filename, "wb") as fd: if i in empty: fd.write(struct.pack("<B", 0)) @@ -379,9 +380,16 @@ def main(): if __name__ == "__main__": + remove_list = [] + try: main() except Exception as ex: print("FATAL: %s\n***" % ex, file=sys.stderr) - traceback.print_exc(ex) + traceback.print_exc() + + for filename in remove_list: + if os.path.exists(filename): + os.unlink(filename) + sys.exit(1) |