-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyLMAT_cs.py
More file actions
executable file
·84 lines (74 loc) · 2.23 KB
/
pyLMAT_cs.py
File metadata and controls
executable file
·84 lines (74 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
#
# Python 3.X site-specific launcher for LMAT run_cs.sh (after run_rl.sh step)
#
# NOTE: the LMAT module should be loaded! Tested module configuration:
# module purge; module load gcc/gcc-4.9.0 python/3.4.0 LMAT/1.2.4
import argparse
import os
import sys
import errno
import subprocess
# pyLMAT release information
__version__ = '0.0.3'
_verdata = 'Jan 2015'
_devflag = True
# > MAIN
# Predefined internal constants
_PATH = './kwashiorkor/'
_FLST = 'rl_output.flst'
# Argument Parser Configuration
parser = argparse.ArgumentParser(
description='pythonic LMAT launcher',
epilog='pyLMAT_cs - DLS team - by J.Mn.Marti - ' + _verdata
)
parser.add_argument(
'-v', '--version',
action='version',
version='pyLMAT.py release ' + __version__ + ' - ' + _verdata
)
parser.add_argument(
'-p', '--path',
action='store',
default=_PATH,
help=('relative path of the data files (if omitted, \'' +
_PATH + '\' will be tried)')
)
# Parse arguments
args = parser.parse_args()
path = args.path
# Program Header
print('\n=-= pyLMAT_cs =-= v' + __version__ + ' =-= ' +
_verdata + ' =-= by DLS team =-=')
if(_devflag):
print('\n>>> WARNING! THIS IS JUST A DEVELOPMENT SUBRELEASE.' +
' USE AT YOUR OWN RISK!')
# LMAT script and options
_pgrm = 'run_cs.sh'
_ilst = '--ilst='
_fsum = '--filesum='
_odir = '--odir='
_ovw = '--overwrite'
(root, dirs, files) = next(os.walk(path))
# Main loop: every subdir in idir
for d in dirs:
(root_, dirs_, files_) = next(os.walk(path + '/' + d))
# 2ndary loop: launch run_cs in processed subdirs
filelst = []
flst = root_ + '/rl_output.flst'
sumf = root_ + '/*.fastsummary'
for f in files_:
if f.endswith('.out'):
filelst.append(root_ + '/' + f + '\n') # EOL for 'writelines'
if len(filelst):
with open(flst, 'w') as lstfile:
lstfile.writelines(filelst)
argums = [_pgrm, _ilst + flst, _fsum + sumf, _odir + root_, _ovw]
print('\tLaunching subprocess: ', argums)
sys.stdout.flush()
try:
p = subprocess.call(argums)
except (PermissionError):
print('\nERROR! Unable to launch ' + repr(_pgrm))
print('TIP: Check if the *right* LMAT module is loaded!\n')
raise