aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPedro de Medeiros <pedro.medeiros@gmail.com>2021-06-02 22:31:12 -0300
committerPedro de Medeiros <pedro.medeiros@gmail.com>2021-06-02 22:31:12 -0300
commit69b4102c996f1793dbc7280924ae023281f94d30 (patch)
tree6613ff9dca3e8380cf222c566601d7a6991301de /tools
parent61bc09a25e83193c68057341bfb33150785b4bcd (diff)
downloadubox-msx-lib-69b4102c996f1793dbc7280924ae023281f94d30.tar.gz
ubox-msx-lib-69b4102c996f1793dbc7280924ae023281f94d30.zip
map.py: remove generated files on error
Diffstat (limited to 'tools')
-rwxr-xr-xtools/map.py10
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)