From c7412771834b3c9e8e4047d3ecaa965590344f1f Mon Sep 17 00:00:00 2001 From: plaa <plaa@dtu.dk> Date: Tue, 10 Jan 2017 11:13:46 +0100 Subject: [PATCH] Suppress output from EllipSys if debug flag is false --- ellipsyswrapper/testsuite.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ellipsyswrapper/testsuite.py b/ellipsyswrapper/testsuite.py index ba63d33..fb60651 100644 --- a/ellipsyswrapper/testsuite.py +++ b/ellipsyswrapper/testsuite.py @@ -178,26 +178,32 @@ class CaseRunner(object): exepath = os.path.join(epath, self.flowfield) command = 'mpirun -np %i python %s' % (self.nprocs, exepath) # out = commands.getoutput(command) - status = subprocess.call(command, shell=True) - if status != 0: - raise RuntimeError('Case %s failed!' % self.casename) - # if self.debug: - # print 'out', out + if self.debug: + status = subprocess.call(command, shell=True) + else: + # Suppress output from EllipSys + FNULL = open(os.devnull, 'w') + status = subprocess.call(command, shell=True,stdout=FNULL) self.read_data(self.project, outname) self.jobid = None + print 'test1' print 'case %s ran in %f seconds' %(self.casename, time.time() - t0) elif self.exec_mode == 'shell': t0 = time.time() exepath = os.path.join(epath, self.flowfield) command = 'mpirun -np %i %s' % (self.nprocs, exepath) - status = subprocess.call(command, shell=True) + if self.debug: + status = subprocess.call(command, shell=True) + else: + # Suppress output from EllipSys + FNULL = open(os.devnull, 'w') + status = subprocess.call(command, shell=True,stdout=FNULL) # status, out = commands.getstatusoutput(command) if status != 0: raise RuntimeError('Case %s failed!' % self.casename) - # elif self.debug: - # print out self.read_data(self.project, outname) self.jobid = None + print 'test2' print 'case %s ran in %f seconds' %(self.casename, time.time() - t0) elif self.exec_mode == 'dry_run': print 'Running in dry run mode, copying pre-computed data!' -- GitLab