polishing and shortening
This commit is contained in:
parent
5ae238d484
commit
3f5d92b9a4
|
@ -5,34 +5,38 @@
|
||||||
import os
|
import os
|
||||||
from damask import Environment
|
from damask import Environment
|
||||||
|
|
||||||
|
BOLD = '\033[1m'
|
||||||
|
ENDC = '\033[0m'
|
||||||
|
|
||||||
damaskEnv = Environment()
|
damaskEnv = Environment()
|
||||||
baseDir = damaskEnv.relPath('processing/')
|
baseDir = damaskEnv.relPath('processing/')
|
||||||
codeDir = damaskEnv.relPath('code/')
|
codeDir = damaskEnv.relPath('code/')
|
||||||
try:
|
try:
|
||||||
binDir = damaskEnv.options['DAMASK_BIN']
|
binDir = damaskEnv.options['DAMASK_BIN']
|
||||||
except:
|
except:
|
||||||
root=os.access('/usr/local/bin', os.W_OK)
|
binDir = '/usr/local/bin' if os.access('/usr/local/bin', os.W_OK) else os.path.join(os.getenv('HOME'),'bin')
|
||||||
if root:
|
|
||||||
binDir = '/usr/local/bin'
|
|
||||||
else:
|
|
||||||
binDir = os.path.join(os.getenv('HOME'),'bin')
|
|
||||||
|
|
||||||
if not os.path.isdir(binDir):
|
if not os.path.isdir(binDir):
|
||||||
os.mkdir(binDir)
|
os.mkdir(binDir)
|
||||||
|
|
||||||
#define ToDo list
|
#define ToDo list
|
||||||
bin_link = ['pre','post','misc']
|
processing_subDirs = ['pre','post','misc',]
|
||||||
|
processing_extensions = ['.py',]
|
||||||
|
|
||||||
|
for subDir in processing_subDirs:
|
||||||
|
theDir = os.path.abspath(os.path.join(baseDir,subDir))
|
||||||
|
|
||||||
|
for theFile in os.listdir(theDir):
|
||||||
|
if os.path.splitext(theFile)[1] in processing_extensions: # omit anything not fitting our script extensions (skip .py.bak, .py~, and the like)
|
||||||
|
|
||||||
|
src = os.path.abspath(os.path.join(theDir,theFile))
|
||||||
|
sym_link = os.path.abspath(os.path.join(binDir,os.path.splitext(theFile)[0]))
|
||||||
|
|
||||||
for myDir in bin_link:
|
|
||||||
myDir = os.path.abspath(os.path.join(baseDir,myDir))
|
|
||||||
for myFile in os.listdir(myDir):
|
|
||||||
if os.path.splitext(myFile)[1] in ['.py']: #only link to know extension, otherwise .py.bak or somethink like that is uses
|
|
||||||
src = os.path.abspath(os.path.join(myDir,myFile))
|
|
||||||
sym_link = os.path.abspath(os.path.join(binDir,os.path.splitext(myFile)[0]))
|
|
||||||
print sym_link,'-->',src
|
|
||||||
if os.path.lexists(sym_link):
|
if os.path.lexists(sym_link):
|
||||||
os.remove(sym_link)
|
os.remove(sym_link)
|
||||||
|
print sym_link,
|
||||||
|
else:
|
||||||
|
print BOLD + sym_link + ENDC,
|
||||||
|
|
||||||
os.symlink(src,sym_link)
|
os.symlink(src,sym_link)
|
||||||
|
print '-->',src
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue