From 88de7f96e7082b872ee9118828e64f552b1ca41f Mon Sep 17 00:00:00 2001 From: Andreas Freise <adf@star.bham.ac.uk> Date: Thu, 16 Jan 2014 16:06:01 +0000 Subject: [PATCH] chaning error behaviour a little: if Finesse returns an error I would prefer to just print that and exit(1). --- pykat/finesse.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/pykat/finesse.py b/pykat/finesse.py index 97e2827..196010e 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -444,25 +444,25 @@ class kat(object): cmd.append('-format=%.15g') cmd.append(katfile.name) - - #if self.verbose: - #print cmd - + p=subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) err = "" #if self.verbose: print "Finesse output:" - + for line in iter(p.stderr.readline, ""): - if len(line) > 0 and printerr == 1: + if len(line) > 0: if line.rstrip().endswith('%'): vals = line.split("-") action = vals[0].strip() prc = vals[1].strip()[:-1] - sys.stdout.write("\r{0} {1}%".format(action, prc)) + if printerr == 1: + sys.stdout.write("\r{0} {1}%".format(action, prc)) elif line[0:3] == '** ': if self.verbose: sys.stdout.write(line) + else: + err += line [out,errpipe] = p.communicate() if printout == 1: @@ -476,13 +476,12 @@ class kat(object): r.katVersion = out[ix:ix2] r.runDateTime = datetime.datetime.now() - + + # If Finesse returned an error, just print that and exit! if p.returncode != 0: - raise pkex.FinesseRunError(err, katfile.name) + print err + sys.exit(1) - #if printout == 1: print out - #if printerr == 1: print err - root = os.path.splitext(katfile.name) base = os.path.basename(root[0]) outfile = root[0] + ".out" -- GitLab