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__),'../../../'))
def get_options(self):
if os.path.isfile(os.path.join(os.getenv('HOME'),'.damask/damask.conf')):
configFile = os.path.join(os.getenv('HOME'),'.damask/damask.conf')
else:
configFile = '/etc/damask.conf'
with open(self.relPath(configFile)) as file:
for line in file:
with open(self.relPath(self.rootDir()+'/CONFIG')) as configFile:
for line in configFile:
l = line.strip()
if not (l.startswith('#') or l == ''):
if l and not l.startswith('#'):
items = l.split('=') + ['','']
if items[1] != '': # nothing specified
self.options[items[0].upper()] = items[1]