python env reads from $DAMASK_ROOT/CONFIG

This commit is contained in:
Martin Diehl 2016-07-13 22:31:38 +02:00
parent 091b72c3ff
commit 0fbb56a6ef
2 changed files with 11 additions and 7 deletions

8
CONFIG Normal file
View File

@ -0,0 +1,8 @@
MSC_ROOT=/opt/MSC
MARC_VERSION=2015
DAMASK_NUM_THREADS=4
ABAQUS_VERSION=6.14-5
#Set DAMASK_BIN if not $DAMASK_ROOT/bin
#DAMASK_BIN

View File

@ -21,14 +21,10 @@ class Environment():
return os.path.normpath(os.path.join(os.path.realpath(__file__),'../../../')) return os.path.normpath(os.path.join(os.path.realpath(__file__),'../../../'))
def get_options(self): def get_options(self):
if os.path.isfile(os.path.join(os.getenv('HOME'),'.damask/damask.conf')): with open(self.relPath(self.rootDir()+'/CONFIG')) as configFile:
configFile = os.path.join(os.getenv('HOME'),'.damask/damask.conf') for line in configFile:
else:
configFile = '/etc/damask.conf'
with open(self.relPath(configFile)) as file:
for line in file:
l = line.strip() l = line.strip()
if not (l.startswith('#') or l == ''): if l and not l.startswith('#'):
items = l.split('=') + ['',''] items = l.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]