From d7afb27322beda6fd42b23957b7a46c774205b05 Mon Sep 17 00:00:00 2001 From: Matt Guthaus Date: Thu, 10 Nov 2016 07:27:38 -0800 Subject: [PATCH] Break subprocess call into arg list. --- compiler/characterizer/charutils.py | 6 +++++- compiler/characterizer/stimuli.py | 27 ++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/compiler/characterizer/charutils.py b/compiler/characterizer/charutils.py index 8f5952e7..472f5d12 100644 --- a/compiler/characterizer/charutils.py +++ b/compiler/characterizer/charutils.py @@ -27,7 +27,11 @@ def relative_compare(value1,value2): def parse_output(filename, key): """Parses a hspice output.lis file for a key value""" - f = open("{0}/{1}.lis".format(OPTS.openram_temp, filename), "r") + full_filename="{0}{1}.lis".format(OPTS.openram_temp, filename) + try: + f = open(full_fliename, "r") + except: + debug.error("Unable to read spice output file: {0}".format(full_filename),1) contents = f.read() val = re.search(r"{0}\s*=\s*(-?\d+.?\d*\S*)\s+.*".format(key), contents) if val != None: diff --git a/compiler/characterizer/stimuli.py b/compiler/characterizer/stimuli.py index 52fd3350..b9d9c710 100644 --- a/compiler/characterizer/stimuli.py +++ b/compiler/characterizer/stimuli.py @@ -447,20 +447,21 @@ def run_sim(): temp_stim = "{0}stim.sp".format(OPTS.openram_temp) if OPTS.spice_version == "hspice": # TODO: Should make multithreading parameter a configuration option - cmd_args = "-mt 8 -i {1} -o {2}timing 2>&1 /dev/null".format(OPTS.spice_exe, - temp_stim, - OPTS.openram_temp) + cmd_args = [OPTS.spice_exe, "-mt 8", "-i {0}".format(temp_stim), "-o {0}timing".format(OPTS.openram_temp)] + valid_retcode=0 else: - cmd_args = "-b -i {1} -o {2}timing.lis 2>&1 /dev/null".format(OPTS.spice_exe, - temp_stim, - OPTS.openram_temp) - - FNULL = open(os.devnull, 'w') - debug.info(2, OPTS.spice_exe + " " + cmd_args) - retcode = subprocess.call([OPTS.spice_exe, cmd_args], stdout=FNULL, stderr=FNULL) - FNULL.close() - - if (retcode > 0): + cmd_args = [OPTS.spice_exe, "-b", "-o {0}timing.lis".format(OPTS.openram_temp), "{0}".format(temp_stim)] + # for some reason, ngspice-25 returns 1 when it only has acceptable warnings + valid_retcode=1 + + spice_stdout = open("{0}spice_stdout.log".format(OPTS.openram_temp), 'w') + spice_stderr = open("{0}spice_stderr.log".format(OPTS.openram_temp), 'w') + debug.info(1, " ".join(cmd_args)) + retcode = subprocess.call(cmd_args, stdout=spice_stdout, stderr=spice_stderr) + spice_stdout.close() + spice_stderr.close() + + if (retcode > valid_retcode): debug.error("Spice simulation error: " + OPTS.spice_exe + " " + cmd_args) sys.exit(-1)