DAMASK_EICMD/installation/symlink_Processing.py

36 lines
1.1 KiB
Python
Raw Normal View History

#!/usr/bin/env python2
# -*- coding: UTF-8 no BOM -*-
# Makes postprocessing routines acessible from everywhere.
import os,sys
import damask
damaskEnv = damask.Environment()
2014-01-24 19:17:46 +05:30
baseDir = damaskEnv.relPath('processing/')
binDir = damaskEnv.options['DAMASK_BIN']
if not os.path.isdir(binDir):
os.mkdir(binDir)
#define ToDo list
2014-04-11 00:55:23 +05:30
processing_subDirs = ['pre','post','misc',]
processing_extensions = ['.py','.sh',]
2014-04-11 00:55:23 +05:30
for subDir in processing_subDirs:
theDir = os.path.abspath(os.path.join(baseDir,subDir))
2014-04-11 00:55:23 +05:30
for theFile in os.listdir(theDir):
2016-04-25 00:38:05 +05:30
if os.path.splitext(theFile)[1] in processing_extensions: # only consider files with proper extensions
2014-04-11 00:55:23 +05:30
src = os.path.abspath(os.path.join(theDir,theFile))
sym_link = os.path.abspath(os.path.join(binDir,os.path.splitext(theFile)[0]))
if os.path.lexists(sym_link):
os.remove(sym_link)
sys.stdout.write(sym_link)
2014-04-11 00:55:23 +05:30
else:
sys.stdout.write(damask.util.bcolors.BOLD + sym_link + damask.util.bcolors.ENDC)
2014-04-11 00:55:23 +05:30
os.symlink(src,sym_link)
sys.stdout.write(' -> '+src+'\n')