check for existence of files before sym-linking to them.

This commit is contained in:
Philip Eisenlohr 2012-11-14 09:40:45 +00:00
parent 0513bf3256
commit ad9639f2f7
1 changed files with 26 additions and 26 deletions

View File

@ -45,7 +45,7 @@ architectures = {
} }
bin_link = { \ bin_link = { \
'' : [ '.' : [
'DAMASK_spectral.exe', 'DAMASK_spectral.exe',
], ],
} }
@ -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.remove(sym_link)
os.symlink(src,sym_link) os.symlink(src,sym_link)
print sym_link,'-->',src