From 420ce01b46d2db06e0132e5f18f0e0dcd86949ba Mon Sep 17 00:00:00 2001 From: Eren Dogan Date: Thu, 4 May 2023 20:27:59 -0700 Subject: [PATCH] Throw error if can't make temp directory --- compiler/globals.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/globals.py b/compiler/globals.py index 60442e99b..2fec7959b 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -475,18 +475,20 @@ def find_exe(check_exe): def init_paths(): - """ Create the temp and output directory if it doesn't exist """ + """ Create the temp and output directory if it doesn't exist. """ + if os.path.exists(OPTS.openram_temp): purge_temp() else: - # make the directory if it doesn't exist + # Make the directory if it doesn't exist try: - debug.info(1, - "Creating temp directory: {}".format(OPTS.openram_temp)) + debug.info(1, "Creating temp directory: {}".format(OPTS.openram_temp)) os.makedirs(OPTS.openram_temp, 0o750) except OSError as e: - if e.errno == 17: # errno.EEXIST + if e.errno == 17: # errno.EEXIST os.chmod(OPTS.openram_temp, 0o750) + else: + debug.error("Unable to make temp directory: {}".format(OPTS.openram_temp), -1) #import inspect #s = inspect.stack() #from pprint import pprint @@ -499,10 +501,10 @@ def init_paths(): try: os.makedirs(OPTS.output_path, 0o750) except OSError as e: - if e.errno == 17: # errno.EEXIST + if e.errno == 17: # errno.EEXIST os.chmod(OPTS.output_path, 0o750) - except: - debug.error("Unable to make output directory.", -1) + else: + debug.error("Unable to make output directory: {}".format(OPTS.output_path), -1) def set_default_corner():