diff options
author | David Wragg <david@rabbitmq.com> | 2011-01-13 11:23:01 +0000 |
---|---|---|
committer | David Wragg <david@rabbitmq.com> | 2011-01-13 11:23:01 +0000 |
commit | 05e233ca7d7f75eec9d7c5ab45ab60aff29a53a0 (patch) | |
tree | a568f509d60a0c3b912d47f03393d19e72313571 /amqp_codegen.py | |
parent | f5792830b0360ead4f93c415d5a60ac8f498d810 (diff) | |
download | rabbitmq-codegen-05e233ca7d7f75eec9d7c5ab45ab60aff29a53a0.tar.gz |
Don't delete the output file before closing it
Windows won't let you, and produces an error, disguising whatever
error led us to try to delete the output file in the first place.
Diffstat (limited to 'amqp_codegen.py')
-rw-r--r-- | amqp_codegen.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/amqp_codegen.py b/amqp_codegen.py index a10cc6d..f265962 100644 --- a/amqp_codegen.py +++ b/amqp_codegen.py @@ -32,7 +32,7 @@ from __future__ import nested_scopes import re import sys -from os import remove +import os from optparse import OptionParser try: @@ -271,16 +271,16 @@ def do_main_dict(funcDict): def execute(fn, amqp_specs, out_file): stdout = sys.stdout f = open(out_file, 'w') + success = False try: - try: - sys.stdout = f - fn(amqp_specs) - except: - remove(out_file) - raise + sys.stdout = f + fn(amqp_specs) + success = True finally: sys.stdout = stdout f.close() + if not success: + os.remove(out_file) parser = OptionParser() parser.add_option("--ignore-conflicts", action="store_true", dest="ignore_conflicts", default=False) |