updated symlinking, removed unused "rootRelation"

This commit is contained in:
Martin Diehl 2016-07-14 15:09:25 +02:00
parent 72d60039c1
commit 3314e5f051
5 changed files with 25 additions and 34 deletions

1
.gitignore vendored
View File

@ -4,4 +4,5 @@
*.exe
*.bak
*~
bin
PRIVATE

9
CONFIG
View File

@ -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

View File

@ -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')

View File

@ -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')

View File

@ -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]
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,