diff --git a/.gitignore b/.gitignore index ea92bb425..d195179bb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ *.exe *.bak *~ +bin PRIVATE diff --git a/CONFIG b/CONFIG index 17561c9cd..ee7e4fae2 100644 --- a/CONFIG +++ b/CONFIG @@ -1,9 +1,10 @@ # "set"-syntax needed only for tcsh (but works with bash and zsh) +# DAMASK_ROOT will be expanded +set DAMASK_BIN=${DAMASK_ROOT}/bin + +set DAMASK_NUM_THREADS = 4 set MSC_ROOT=/opt/MSC set MARC_VERSION=2015 -set DAMASK_NUM_THREADS = 4 - -set ABAQUS_VERSION=6.14-5 -set DAMASK_BIN=${DAMASK_ROOT}/lib +set ABAQUS_VERSION=5.14-5 diff --git a/installation/symlink_Code.py b/installation/symlink_Code.py index f0fea41e3..5d4518ddd 100755 --- a/installation/symlink_Code.py +++ b/installation/symlink_Code.py @@ -13,16 +13,9 @@ bin_link = { \ MarcReleases =[2011,2012,2013,2013.1,2014,2014.2,2015] -baseDir = damask.Environment('../../').relPath('code/') - -try: - binDir = damask.Environment().options['DAMASK_BIN'] -except: - root=os.access('/usr/local/bin', os.W_OK) - if root: - binDir = '/usr/local/bin' - else: - binDir = os.path.join(os.getenv('HOME'),'bin') +damaskEnv = damask.Environment() +baseDir = damaskEnv.relPath('code/') +binDir = damaskEnv.options['DAMASK_BIN'] if not os.path.isdir(binDir): os.mkdir(binDir) @@ -43,7 +36,11 @@ for version in MarcReleases: src = os.path.abspath(os.path.join(baseDir,'DAMASK_marc.f90')) if os.path.exists(src): sym_link = os.path.abspath(os.path.join(baseDir,'DAMASK_marc'+str(version)+'.f90')) - if os.path.lexists(sym_link): os.remove(sym_link) - os.symlink(os.path.relpath(src,baseDir),sym_link) - sys.stdout.write(sym_link+' -> '+src+'\n') + if os.path.lexists(sym_link): + os.remove(sym_link) + sys.stdout.write(sym_link) + else: + sys.stdout.write(damask.util.bcolors.BOLD + sym_link + damask.util.bcolors.ENDC) + os.symlink(src,sym_link) + sys.stdout.write(' -> '+src+'\n') diff --git a/installation/symlink_Processing.py b/installation/symlink_Processing.py index 0ca4f8ba4..3f00e95c6 100755 --- a/installation/symlink_Processing.py +++ b/installation/symlink_Processing.py @@ -3,18 +3,11 @@ # Makes postprocessing routines acessible from everywhere. import os,sys -from damask import Environment +import damask -BOLD = '\033[1m' -ENDC = '\033[0m' - -damaskEnv = Environment() +damaskEnv = damask.Environment() baseDir = damaskEnv.relPath('processing/') -codeDir = damaskEnv.relPath('code/') -try: - binDir = damaskEnv.options['DAMASK_BIN'] -except: - binDir = '/usr/local/bin' if os.access('/usr/local/bin', os.W_OK) else os.path.join(os.getenv('HOME'),'bin') +binDir = damaskEnv.options['DAMASK_BIN'] if not os.path.isdir(binDir): os.mkdir(binDir) @@ -36,7 +29,7 @@ for subDir in processing_subDirs: os.remove(sym_link) sys.stdout.write(sym_link) else: - sys.stdout.write(BOLD + sym_link + ENDC) + sys.stdout.write(damask.util.bcolors.BOLD + sym_link + damask.util.bcolors.ENDC) os.symlink(src,sym_link) sys.stdout.write(' -> '+src+'\n') diff --git a/lib/damask/environment.py b/lib/damask/environment.py index b0256e05d..4d24c6c6e 100644 --- a/lib/damask/environment.py +++ b/lib/damask/environment.py @@ -5,12 +5,10 @@ import os,subprocess,shlex,re class Environment(): __slots__ = [ \ - 'rootRelation', 'options', ] - def __init__(self,rootRelation = '.'): - self.rootRelation = rootRelation + def __init__(self): self.options = {} self.get_options() @@ -23,11 +21,12 @@ class Environment(): def get_options(self): with open(self.relPath(self.rootDir()+'/CONFIG')) as configFile: for line in configFile: - l = re.sub('^set ', '', line).strip() + l = re.sub('^set ', '', line).strip() # remove "set" (tcsh) when setting variables if l and not l.startswith('#'): items = l.split('=') - if len(items) == 2: - self.options[items[0].upper()] = items[1] + if len(items) == 2: + self.options[items[0].upper()] = \ + re.sub('\$\{*DAMASK_ROOT\}*',self.rootDir(),os.path.expandvars(items[1])) # expand all shell variables and DAMASK_ROOT def isAvailable(self,software,Nneeded =-1): licensesNeeded = {'abaqus' :5,