syntax polishing
This commit is contained in:
parent
b590beb712
commit
50b682db4c
|
@ -22,44 +22,40 @@ class Environment():
|
||||||
if sys.argv[0] == '': # no caller path
|
if sys.argv[0] == '': # no caller path
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
else:
|
else:
|
||||||
cwd = {False: os.path.dirname(sys.argv[0]),
|
cwd = sys.argv[0] if os.path.isdir(sys.argv[0]) else os.path.dirname(sys.argv[0])
|
||||||
True: sys.argv[0]}[os.path.isdir(sys.argv[0])]
|
|
||||||
damask_root = os.path.normpath(os.path.join(os.path.realpath(cwd),self.rootRelation))
|
damask_root = os.path.normpath(os.path.join(os.path.realpath(cwd),self.rootRelation))
|
||||||
|
|
||||||
return damask_root
|
return damask_root
|
||||||
|
|
||||||
def binDir(self):
|
def binDir(self):
|
||||||
damask_bin = os.getenv('DAMASK_BIN')
|
damask_bin = os.getenv('DAMASK_BIN')
|
||||||
if damask_bin == '' or damask_bin == None: damask_bin = self.relPath('bin/')
|
if damask_bin == '' or damask_bin == None: damask_bin = self.relPath('bin/')
|
||||||
return damask_bin
|
return damask_bin
|
||||||
|
|
||||||
def get_options(self):
|
def get_options(self):
|
||||||
try: # check for user-defined pathinfo
|
with open(self.relPath('installation/options')) as file:
|
||||||
file = open(self.relPath('installation/options'))
|
for line in file:
|
||||||
content = map(lambda string: string.strip(),file.readlines())
|
l = line.strip()
|
||||||
file.close()
|
if not (l.startswith('#') or l == ''):
|
||||||
for line in content:
|
items = l.split('=') + ['','']
|
||||||
if not (line.startswith('#') or line == ''):
|
|
||||||
items = line.split('=') + ['','']
|
|
||||||
if items[1] != '': # nothing specified
|
if items[1] != '': # nothing specified
|
||||||
self.options[items[0].upper()] = items[1]
|
self.options[items[0].upper()] = items[1]
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def isAvailable(self,software,noNeeded=-1):
|
def isAvailable(self,software,Nneeded =-1):
|
||||||
licensesNeeded = {'abaqus' :5,
|
licensesNeeded = {'abaqus' :5,
|
||||||
'standard':5,
|
'standard':5,
|
||||||
'explicit':5}
|
'explicit':5}
|
||||||
if noNeeded == -1: noNeeded = licensesNeeded[software]
|
if Nneeded == -1: Nneeded = licensesNeeded[software]
|
||||||
cmd = """ ssh mulicense2 "/Stat_Flexlm | grep 'Users of %s: ' | cut -d' ' -f7,13" """%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)
|
process = subprocess.Popen(shlex.split(cmd),stdout = subprocess.PIPE,stderr = subprocess.PIPE)
|
||||||
licenses = map(int, process.stdout.readline().split())
|
licenses = map(int, process.stdout.readline().split())
|
||||||
try:
|
try:
|
||||||
if licenses[0]-licenses[1] >= noNeeded:
|
if licenses[0]-licenses[1] >= Nneeded:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
print(licenses[1] + noNeeded - licenses[0], 'missing licenses for %s'%software)
|
print(licenses[1] + Nneeded - licenses[0], 'missing licenses for %s'%software)
|
||||||
return licenses[1] + noNeeded - licenses[0]
|
return licenses[1] + Nneeded - licenses[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print('Could not retrieve license information for %s'%software)
|
print('Could not retrieve license information for %s'%software)
|
||||||
return 127
|
return 127
|
||||||
|
|
Loading…
Reference in New Issue