check for existence of files before sym-linking to them.
This commit is contained in:
parent
0513bf3256
commit
ad9639f2f7
|
@ -45,30 +45,30 @@ architectures = {
|
||||||
}
|
}
|
||||||
|
|
||||||
bin_link = { \
|
bin_link = { \
|
||||||
'' : [
|
'.' : [
|
||||||
'DAMASK_spectral.exe',
|
'DAMASK_spectral.exe',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
damaskEnv = damask.Environment('../../') # script location relative to root
|
damaskEnv = damask.Environment('../../') # script location relative to root
|
||||||
baseDir = damaskEnv.relPath('code/')
|
baseDir = damaskEnv.relPath('code/')
|
||||||
|
|
||||||
for arch in architectures:
|
for arch in architectures:
|
||||||
me = architectures[arch]
|
me = architectures[arch]
|
||||||
try:
|
try:
|
||||||
parentFile = open(baseDir+os.sep+me['parent'])
|
parentFile = open(baseDir+os.sep+me['parent'])
|
||||||
parentContent = parentFile.readlines()
|
parentContent = parentFile.readlines()
|
||||||
parentFile.close()
|
parentFile.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
print 'unable to open',me['parent']
|
print 'unable to open',me['parent']
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
for version in me['versions'][1:]:
|
for version in me['versions'][1:]:
|
||||||
childFile = open(baseDir+os.sep+version.join(os.path.splitext(me['parent'])),'w')
|
childFile = open(baseDir+os.sep+version.join(os.path.splitext(me['parent'])),'w')
|
||||||
for line in parentContent:
|
for line in parentContent:
|
||||||
childFile.write(line.replace(me['versions'][0],version))
|
childFile.write(line.replace(me['versions'][0],version))
|
||||||
childFile.close()
|
childFile.close()
|
||||||
|
|
||||||
# changing dirs in makefile
|
# changing dirs in makefile
|
||||||
makefile = open(os.path.join(baseDir,'Makefile'))
|
makefile = open(os.path.join(baseDir,'Makefile'))
|
||||||
|
@ -91,14 +91,14 @@ if (options.spectralCompile):
|
||||||
os.system('make --directory %s clean'%(baseDir))
|
os.system('make --directory %s clean'%(baseDir))
|
||||||
os.system('make --directory %s %s'%(baseDir,' '.join(options.makeOptions)))
|
os.system('make --directory %s %s'%(baseDir,' '.join(options.makeOptions)))
|
||||||
|
|
||||||
|
# processing symbolic linking list
|
||||||
for dir in bin_link:
|
for dir in bin_link:
|
||||||
for file in bin_link[dir]:
|
for file in bin_link[dir]:
|
||||||
src = os.path.abspath(os.path.join(baseDir,dir,file))
|
src = os.path.abspath(os.path.join(baseDir,dir,file))
|
||||||
if (file == ''):
|
if os.path.exists(src):
|
||||||
sym_link = os.path.abspath(os.path.join(damaskEnv.binDir(),dir))
|
sym_link = os.path.abspath(os.path.join(damaskEnv.binDir(),\
|
||||||
else:
|
{True: dir,
|
||||||
sym_link = os.path.abspath(os.path.join(damaskEnv.binDir(),os.path.splitext(file)[0]))
|
False:os.path.splitext(file)[0]}[file == '']))
|
||||||
print sym_link,'-->',src
|
if os.path.lexists(sym_link): os.remove(sym_link)
|
||||||
if os.path.lexists(sym_link):
|
os.symlink(src,sym_link)
|
||||||
os.remove(sym_link)
|
print sym_link,'-->',src
|
||||||
os.symlink(src,sym_link)
|
|
||||||
|
|
Loading…
Reference in New Issue