2016-05-11 14:31:39 +05:30
|
|
|
#!/usr/bin/env python2
|
2014-04-02 00:11:14 +05:30
|
|
|
# -*- coding: UTF-8 no BOM -*-
|
2014-01-11 18:16:30 +05:30
|
|
|
|
|
|
|
# Makes postprocessing routines acessible from everywhere.
|
2014-04-29 20:13:04 +05:30
|
|
|
import os,sys
|
2014-01-11 18:16:30 +05:30
|
|
|
from damask import Environment
|
|
|
|
|
2014-04-11 00:55:23 +05:30
|
|
|
BOLD = '\033[1m'
|
|
|
|
ENDC = '\033[0m'
|
|
|
|
|
2014-01-11 18:16:30 +05:30
|
|
|
damaskEnv = Environment()
|
2014-01-24 19:17:46 +05:30
|
|
|
baseDir = damaskEnv.relPath('processing/')
|
2014-01-11 18:16:30 +05:30
|
|
|
codeDir = damaskEnv.relPath('code/')
|
2014-02-28 13:17:11 +05:30
|
|
|
try:
|
|
|
|
binDir = damaskEnv.options['DAMASK_BIN']
|
|
|
|
except:
|
2014-04-11 00:55:23 +05:30
|
|
|
binDir = '/usr/local/bin' if os.access('/usr/local/bin', os.W_OK) else os.path.join(os.getenv('HOME'),'bin')
|
2014-02-28 13:17:11 +05:30
|
|
|
|
|
|
|
if not os.path.isdir(binDir):
|
|
|
|
os.mkdir(binDir)
|
2014-01-11 18:16:30 +05:30
|
|
|
|
|
|
|
#define ToDo list
|
2014-04-11 00:55:23 +05:30
|
|
|
processing_subDirs = ['pre','post','misc',]
|
2016-04-25 00:06:23 +05:30
|
|
|
processing_extensions = ['.py','.sh',]
|
2014-01-11 18:16:30 +05:30
|
|
|
|
2014-04-11 00:55:23 +05:30
|
|
|
for subDir in processing_subDirs:
|
|
|
|
theDir = os.path.abspath(os.path.join(baseDir,subDir))
|
2014-01-11 18:16:30 +05:30
|
|
|
|
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-01-11 18:16:30 +05:30
|
|
|
|
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)
|
2014-04-29 20:13:04 +05:30
|
|
|
sys.stdout.write(sym_link)
|
2014-04-11 00:55:23 +05:30
|
|
|
else:
|
2014-04-29 20:13:04 +05:30
|
|
|
sys.stdout.write(BOLD + sym_link + ENDC)
|
2014-01-11 18:16:30 +05:30
|
|
|
|
2014-04-11 00:55:23 +05:30
|
|
|
os.symlink(src,sym_link)
|
2014-04-29 20:13:04 +05:30
|
|
|
sys.stdout.write(' -> '+src+'\n')
|