@@ -247,10 +247,11 @@ def isAvailable(cls):
247
247
running the commandline tool.
248
248
'''
249
249
try :
250
- subprocess .Popen (cls .bin_path (),
250
+ p = subprocess .Popen (cls .bin_path (),
251
251
shell = False ,
252
252
stdout = subprocess .PIPE ,
253
253
stderr = subprocess .PIPE )
254
+ p .communicate ()
254
255
return True
255
256
except OSError :
256
257
return False
@@ -326,6 +327,30 @@ def _frame_sink(self):
326
327
# because it will no longer be referenced and will be gc-ed.
327
328
return open (fname , 'wb' )
328
329
330
+ def grab_frame (self , ** savefig_kwargs ):
331
+ '''
332
+ Grab the image information from the figure and save as a movie frame.
333
+ All keyword arguments in savefig_kwargs are passed on to the 'savefig'
334
+ command that saves the figure.
335
+ '''
336
+ #Overloaded to explicitly close temp file.
337
+ verbose .report ('MovieWriter.grab_frame: Grabbing frame.' ,
338
+ level = 'debug' )
339
+ try :
340
+ # Tell the figure to save its data to the sink, using the
341
+ # frame format and dpi.
342
+ myframesink = self ._frame_sink ()
343
+ self .fig .savefig (myframesink , format = self .frame_format ,
344
+ dpi = self .dpi , ** savefig_kwargs )
345
+ myframesink .close ()
346
+
347
+ except RuntimeError :
348
+ out , err = self ._proc .communicate ()
349
+ verbose .report ('MovieWriter -- Error '
350
+ 'running proc:\n %s\n %s' % (out ,
351
+ err ), level = 'helpful' )
352
+ raise
353
+
329
354
def finish (self ):
330
355
# Call run here now that all frame grabbing is done. All temp files
331
356
# are available to be assembled.
0 commit comments