diff --git a/lib/damask/environment.py b/lib/damask/environment.py index 9235d9f11..bd3674775 100644 --- a/lib/damask/environment.py +++ b/lib/damask/environment.py @@ -1,6 +1,6 @@ # $Id$ -import os,sys,string,re +import os,sys,string,re,subprocess,shlex class Environment(): __slots__ = [ \ @@ -49,4 +49,21 @@ class Environment(): self.pathInfo[items[0].lower()] = os.path.normpath(os.path.join(self.relPath('lib/'),items[1])) except: pass - + + def isAvailable(self,software,noNeeded=-1): + licensesNeeded = {'abaqus' :5, + 'standard':5, + 'explicit':5} + if noNeeded == -1: noNeeded = licensesNeeded[software] + cmd = """ ssh mulicense2 "/Stat_Flexlm | grep 'Users of %s: ' | cut -d' ' -f7,13" """%software + process = subprocess.Popen(shlex.split(cmd),stdout = subprocess.PIPE,stderr = subprocess.PIPE) + licenses = map(int, process.stdout.readline().split()) + try: + if licenses[0]-licenses[1] >= noNeeded: + return 0 + else: + print licenses[1] + noNeeded - licenses[0], 'missing licenses for %s'%software + return licenses[1] + noNeeded - licenses[0] + except IndexError: + print 'Could not retrieve license information for %s'%software + return 127 \ No newline at end of file diff --git a/lib/damask/test/test.py b/lib/damask/test/test.py index 07f4696f7..de3ddae74 100644 --- a/lib/damask/test/test.py +++ b/lib/damask/test/test.py @@ -36,6 +36,8 @@ class Test(): ''' Run all variants and report first failure. ''' + if not self.testPossible(): + return -1 if len(update) == 0 and self.options.update: print ' This test has no reference to update' if len(variants) == 0: variants = xrange(len(self.variants)) # iterate over all variants self.clean() @@ -48,12 +50,18 @@ class Test(): if variant in update: self.update(variant) elif not self.compare(variant): - return variant + return variant+1 except Exception,e : print '\nWARNING:\n %s\n'%e - return variant - return -1 - + return variant+1 + return 0 + + def testPossible(self): + ''' + Check if test is possible or not (e.g. no license available). + ''' + return True + def clean(self): ''' Delete directory tree containing current results. @@ -337,12 +345,15 @@ class Test(): def report_Success(self,culprit): - if culprit < 0: + if culprit == 0: print '%s passed.'%({False: 'The test', True: 'All %i tests'%(len(self.variants))}[len(self.variants) > 1]) print '\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' return 0 + if culprit == -1: + print 'Warning: Could not start test' + return 0 else: - print ' ********\n * Test %i failed...\n ********'%(culprit+1) + print ' ********\n * Test %i failed...\n ********'%(culprit) print '\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' - return culprit+1 + return culprit