@@ -91,13 +91,6 @@ def report_nodes_not_run(notrun):
9191 'Check log for details' ))
9292
9393
94- def write_matplotlibrc (batch_dir ):
95- """Set the matplotlib backend in a local rc file."""
96- backend = nipype .config .get ("execution" , "matplotlib_backend" )
97- with open (os .path .join (batch_dir , "matplotlibrc" ), "w" ) as fid :
98- fid .write ("backend : %s" % backend )
99-
100-
10194def create_pyscript (node , updatehash = False , store_exception = True ):
10295 # pickle node
10396 timestamp = strftime ('%Y%m%d_%H%M%S' )
@@ -111,12 +104,14 @@ def create_pyscript(node, updatehash=False, store_exception=True):
111104 batch_dir = os .path .join (node .base_dir , 'batch' )
112105 if not os .path .exists (batch_dir ):
113106 os .makedirs (batch_dir )
114- write_matplotlibrc (batch_dir )
115107 pkl_file = os .path .join (batch_dir , 'node_%s.pklz' % suffix )
116108 savepkl (pkl_file , dict (node = node , updatehash = updatehash ))
109+ mpl_backend = nipype .config .get ("execution" , "matplotlib_backend" )
117110 # create python script to load and trap exception
118111 cmdstr = """import os
119112import sys
113+ import matplotlib
114+ matplotlib.use('%s')
120115from nipype import config, logging
121116from nipype.utils.filemanip import loadpkl, savepkl
122117from socket import gethostname
@@ -162,7 +157,7 @@ def create_pyscript(node, updatehash=False, store_exception=True):
162157 report_crash(info['node'], traceback, gethostname())
163158 raise Exception(e)
164159"""
165- cmdstr = cmdstr % (pkl_file , batch_dir , node .config , suffix )
160+ cmdstr = cmdstr % (mpl_backend , pkl_file , batch_dir , node .config , suffix )
166161 pyscript = os .path .join (batch_dir , 'pyscript_%s.py' % suffix )
167162 fp = open (pyscript , 'wt' )
168163 fp .writelines (cmdstr )
0 commit comments