/usr/bin/nipype_display_crash is in python-nipype 0.11.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 85 | #! /usr/bin/python
"""Displays crash information from Nipype crash files. For certain crash files,
one can rerun a failed node in a temp directory.
Examples:
nipype_display_crash crashfile.pklz
nipype_display_crash crashfile.pklz -r -i
nipype_display_crash crashfile.pklz -r -i
"""
def display_crash_files(crashfile, rerun, debug, directory):
"""display crash file content and rerun if required"""
from nipype.utils.filemanip import loadcrash
crash_data = loadcrash(crashfile)
node = None
if 'node' in crash_data:
node = crash_data['node']
tb = crash_data['traceback']
print("\n")
print("File: %s" % crashfile)
if node:
print("Node: %s" % node)
if node.base_dir:
print("Working directory: %s" % node.output_dir())
else:
print("Node crashed before execution")
print("\n")
print("Node inputs:")
print(node.inputs)
print("\n")
print("Traceback: ")
print(''.join(tb))
print ("\n")
if rerun:
if node is None:
print("No node in crashfile. Cannot rerun")
return
print("Rerunning node")
node.base_dir = directory
node.config = {'execution': {'crashdump_dir': '/tmp'}}
try:
node.run()
except:
if debug and debug != 'ipython':
import pdb
pdb.post_mortem()
else:
raise
print("\n")
if __name__ == "__main__":
from argparse import ArgumentParser, RawTextHelpFormatter
defstr = ' (default %(default)s)'
parser = ArgumentParser(prog='nipype_display_crash',
description=__doc__,
formatter_class=RawTextHelpFormatter)
parser.add_argument('crashfile', metavar='f', type=str,
help='crash file to display')
parser.add_argument('-r','--rerun', dest='rerun',
default=False, action="store_true",
help='rerun crashed node' + defstr)
group = parser.add_mutually_exclusive_group()
group.add_argument('-d','--debug', dest='debug',
default=False, action="store_true",
help='enable python debugger when re-executing' + defstr)
group.add_argument('-i','--ipydebug', dest='ipydebug',
default=False, action="store_true",
help='enable ipython debugger when re-executing' + defstr)
parser.add_argument('--dir', dest='directory',
default=None,
help='Directory to run the node in' + defstr)
args = parser.parse_args()
debug = 'ipython' if args.ipydebug else args.debug
if debug == 'ipython':
import sys
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(mode='Verbose',
color_scheme='Linux',
call_pdb=1)
display_crash_files(args.crashfile, args.rerun,
debug, args.directory)
|