condensed output, DAMASK_marc symlinks are relative, add symlink pruning
This commit is contained in:
parent
d3eb3451e3
commit
eb9f6c939c
|
@ -11,7 +11,15 @@ bin_link = { \
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
MarcReleases =[2011,2012,2013,2013.1,2014,2014.2,2015]
|
MarcReleases =[ \
|
||||||
|
'2011',
|
||||||
|
'2012',
|
||||||
|
'2013',
|
||||||
|
'2013.1',
|
||||||
|
'2014',
|
||||||
|
'2014.2',
|
||||||
|
'2015',
|
||||||
|
]
|
||||||
|
|
||||||
damaskEnv = damask.Environment()
|
damaskEnv = damask.Environment()
|
||||||
baseDir = damaskEnv.relPath('code/')
|
baseDir = damaskEnv.relPath('code/')
|
||||||
|
@ -20,27 +28,41 @@ binDir = damaskEnv.options['DAMASK_BIN']
|
||||||
if not os.path.isdir(binDir):
|
if not os.path.isdir(binDir):
|
||||||
os.mkdir(binDir)
|
os.mkdir(binDir)
|
||||||
|
|
||||||
for dir in bin_link:
|
sys.stdout.write('\nsymbolic linking...\n')
|
||||||
for file in bin_link[dir]:
|
|
||||||
src = os.path.abspath(os.path.join(baseDir,dir,file))
|
|
||||||
if os.path.exists(src):
|
|
||||||
sym_link = os.path.abspath(os.path.join(binDir,\
|
|
||||||
{True: dir,
|
|
||||||
False:os.path.splitext(file)[0]}[file == '']))
|
|
||||||
if os.path.lexists(sym_link): os.remove(sym_link)
|
|
||||||
os.symlink(src,sym_link)
|
|
||||||
sys.stdout.write(sym_link+' -> '+src+'\n')
|
|
||||||
|
|
||||||
|
for subDir in bin_link:
|
||||||
|
theDir = os.path.abspath(os.path.join(baseDir,subDir))
|
||||||
|
sys.stdout.write('\n'+binDir+' ->\n'+theDir+damask.util.deemph(' ...')+'\n')
|
||||||
|
|
||||||
|
for theFile in bin_link[subDir]:
|
||||||
|
theName,theExt = os.path.splitext(theFile)
|
||||||
|
src = os.path.abspath(os.path.join(theDir,theFile))
|
||||||
|
|
||||||
|
if os.path.exists(src):
|
||||||
|
sym_link = os.path.abspath(os.path.join(binDir,subDir if theFile == '' else theName))
|
||||||
|
|
||||||
|
if os.path.lexists(sym_link):
|
||||||
|
os.remove(sym_link)
|
||||||
|
output = theName+damask.util.deemph(theExt)
|
||||||
|
else:
|
||||||
|
output = damask.util.emph(theName)+damask.util.deemph(theExt)
|
||||||
|
|
||||||
|
sys.stdout.write(damask.util.deemph('... ')+output+'\n')
|
||||||
|
os.symlink(src,sym_link)
|
||||||
|
|
||||||
|
|
||||||
|
sys.stdout.write('\nMSC.Marc versioning...\n\n')
|
||||||
|
theMaster = 'DAMASK_marc.f90'
|
||||||
|
|
||||||
for version in MarcReleases:
|
for version in MarcReleases:
|
||||||
src = os.path.abspath(os.path.join(baseDir,'DAMASK_marc.f90'))
|
src = os.path.abspath(os.path.join(baseDir,theMaster))
|
||||||
if os.path.exists(src):
|
if os.path.exists(src):
|
||||||
sym_link = os.path.abspath(os.path.join(baseDir,'DAMASK_marc'+str(version)+'.f90'))
|
sym_link = os.path.abspath(os.path.join(baseDir,'DAMASK_marc{}.f90'.format(version)))
|
||||||
if os.path.lexists(sym_link):
|
if os.path.lexists(sym_link):
|
||||||
os.remove(sym_link)
|
os.remove(sym_link)
|
||||||
sys.stdout.write(sym_link)
|
output = version
|
||||||
else:
|
else:
|
||||||
sys.stdout.write(damask.util.emph(sym_link))
|
output = damask.util.emph(version)
|
||||||
|
|
||||||
os.symlink(src,sym_link)
|
sys.stdout.write(' '+output+'\n')
|
||||||
sys.stdout.write(' -> '+src+'\n')
|
os.symlink(theMaster,sym_link)
|
||||||
|
|
|
@ -13,23 +13,47 @@ if not os.path.isdir(binDir):
|
||||||
os.mkdir(binDir)
|
os.mkdir(binDir)
|
||||||
|
|
||||||
#define ToDo list
|
#define ToDo list
|
||||||
processing_subDirs = ['pre','post','misc',]
|
processing_subDirs = ['pre',
|
||||||
processing_extensions = ['.py','.sh',]
|
'post',
|
||||||
|
'misc',
|
||||||
|
]
|
||||||
|
processing_extensions = ['.py',
|
||||||
|
'.sh',
|
||||||
|
]
|
||||||
|
|
||||||
|
sys.stdout.write('\nsymbolic linking...\n')
|
||||||
|
|
||||||
for subDir in processing_subDirs:
|
for subDir in processing_subDirs:
|
||||||
theDir = os.path.abspath(os.path.join(baseDir,subDir))
|
theDir = os.path.abspath(os.path.join(baseDir,subDir))
|
||||||
|
|
||||||
|
sys.stdout.write('\n'+binDir+' ->\n'+theDir+damask.util.deemph(' ...')+'\n')
|
||||||
|
|
||||||
for theFile in os.listdir(theDir):
|
for theFile in os.listdir(theDir):
|
||||||
if os.path.splitext(theFile)[1] in processing_extensions: # only consider files with proper extensions
|
theName,theExt = os.path.splitext(theFile)
|
||||||
|
if theExt in processing_extensions: # only consider files with proper extensions
|
||||||
|
|
||||||
src = os.path.abspath(os.path.join(theDir,theFile))
|
src = os.path.abspath(os.path.join(theDir,theFile))
|
||||||
sym_link = os.path.abspath(os.path.join(binDir,os.path.splitext(theFile)[0]))
|
sym_link = os.path.abspath(os.path.join(binDir,theName))
|
||||||
|
|
||||||
if os.path.lexists(sym_link):
|
if os.path.lexists(sym_link):
|
||||||
os.remove(sym_link)
|
os.remove(sym_link)
|
||||||
sys.stdout.write(sym_link)
|
output = theName+damask.util.deemph(theExt)
|
||||||
else:
|
else:
|
||||||
sys.stdout.write(damask.util.emph(sym_link))
|
output = damask.util.emph(theName)+damask.util.deemph(theExt)
|
||||||
|
|
||||||
|
sys.stdout.write(damask.util.deemph('... ')+output+'\n')
|
||||||
os.symlink(src,sym_link)
|
os.symlink(src,sym_link)
|
||||||
sys.stdout.write(' -> '+src+'\n')
|
|
||||||
|
|
||||||
|
sys.stdout.write('\npruning broken links...\n')
|
||||||
|
|
||||||
|
brokenLinks = 0
|
||||||
|
|
||||||
|
for filename in os.listdir(binDir):
|
||||||
|
path = os.path.join(binDir,filename)
|
||||||
|
if os.path.islink(path) and not os.path.exists(path):
|
||||||
|
sys.stdout.write(' '+damask.util.delete(path)+'\n')
|
||||||
|
os.remove(path)
|
||||||
|
brokenLinks += 1
|
||||||
|
|
||||||
|
sys.stdout.write(('none.' if brokenLinks == 0 else '')+'\n')
|
||||||
|
|
Loading…
Reference in New Issue