Skip to content

Commit 4eb197f

Browse files
authored
Merge pull request #1596 from alexsavio/master
A few fixes to bin scripts and a proposal of a new one
2 parents 0f2cb9f + e8fb466 commit 4eb197f

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

bin/nipype_crash_search

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#!/usr/bin/env python
1+
#!python
22
"""Search for tracebacks inside a folder of nipype crash
33
log files that match a given regular expression.
44
55
Examples:
66
nipype_crash_search -d nipype/wd/log -r '.*subject123.*'
77
"""
88
import re
9+
import sys
910
import os.path as op
1011
from glob import glob
1112

@@ -60,6 +61,7 @@ def display_crash_search(logdir, regex):
6061

6162
if __name__ == "__main__":
6263
from argparse import ArgumentParser, RawTextHelpFormatter
64+
6365
defstr = ' (default %(default)s)'
6466
parser = ArgumentParser(prog='nipype_crash_search',
6567
description=__doc__,
@@ -71,6 +73,10 @@ if __name__ == "__main__":
7173
default='*',
7274
help='Regular expression to be searched in each traceback.' + defstr)
7375

74-
args = parser.parse_args()
76+
if len(sys.argv) == 1:
77+
parser.print_help()
78+
exit(0)
7579

80+
args = parser.parse_args()
7681
display_crash_search(args.logdir, args.regex)
82+
exit(0)

bin/nipype_display_pklz

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!python
2+
"""Prints the content of any .pklz file in your working directory.
3+
4+
Examples:
5+
6+
nipype_print_pklz _inputs.pklz
7+
nipype_print_pklz _node.pklz
8+
"""
9+
10+
def pprint_pklz_file(pklz_file):
11+
""" Print the content of the pklz_file. """
12+
from pprint import pprint
13+
from nipype.utils.filemanip import loadpkl
14+
15+
pkl_data = loadpkl(pklz_file)
16+
pprint(pkl_data)
17+
18+
19+
if __name__ == "__main__":
20+
21+
import sys
22+
from argparse import ArgumentParser, RawTextHelpFormatter
23+
24+
defstr = ' (default %(default)s)'
25+
parser = ArgumentParser(prog='nipype_print_pklz',
26+
description=__doc__,
27+
formatter_class=RawTextHelpFormatter)
28+
parser.add_argument('pklzfile', metavar='f', type=str,
29+
help='pklz file to display')
30+
31+
if len(sys.argv) == 1:
32+
parser.print_help()
33+
exit(0)
34+
35+
args = parser.parse_args()
36+
pprint_pklz_file(args.pklzfile)

0 commit comments

Comments
 (0)