@@ -364,22 +364,14 @@ def grab_frame(self, **savefig_kwargs):
364364 command that saves the figure.
365365 '''
366366 _log .debug ('MovieWriter.grab_frame: Grabbing frame.' )
367- try :
368- # re-adjust the figure size in case it has been changed by the
369- # user. We must ensure that every frame is the same size or
370- # the movie will not save correctly.
371- self .fig .set_size_inches (self ._w , self ._h )
372- # Tell the figure to save its data to the sink, using the
373- # frame format and dpi.
374- self .fig .savefig (self ._frame_sink (), format = self .frame_format ,
375- dpi = self .dpi , ** savefig_kwargs )
376- except (RuntimeError , IOError ) as e :
377- out , err = self ._proc .communicate ()
378- _log .info ('MovieWriter -- Error running proc:\n %s\n %s' , out , err )
379- raise IOError ('Error saving animation to file (cause: {0}) '
380- 'Stdout: {1} StdError: {2}. It may help to re-run '
381- 'with logging level set to '
382- 'DEBUG.' .format (e , out , err ))
367+ # re-adjust the figure size in case it has been changed by the
368+ # user. We must ensure that every frame is the same size or
369+ # the movie will not save correctly.
370+ self .fig .set_size_inches (self ._w , self ._h )
371+ # Tell the figure to save its data to the sink, using the
372+ # frame format and dpi.
373+ self .fig .savefig (self ._frame_sink (), format = self .frame_format ,
374+ dpi = self .dpi , ** savefig_kwargs )
383375
384376 def _frame_sink (self ):
385377 '''Returns the place to which frames should be written.'''
@@ -396,15 +388,15 @@ def cleanup(self):
396388 # Use the encoding/errors that universal_newlines would use.
397389 out = TextIOWrapper (BytesIO (out )).read ()
398390 err = TextIOWrapper (BytesIO (err )).read ()
399- _log .debug ("MovieWriter stdout:\n %s" , out )
400- _log .debug ("MovieWriter stderr:\n %s" , err )
391+ _log .log (
392+ logging .WARNING if self ._proc .returncode else logging .DEBUG ,
393+ "MovieWriter stdout:\n %s" , out )
394+ _log .log (
395+ logging .WARNING if self ._proc .returncode else logging .DEBUG ,
396+ "MovieWriter stderr:\n %s" , err )
401397 if self ._proc .returncode :
402- raise RuntimeError ('Error creating movie, return code {}\n '
403- 'stdout:\n '
404- '{}\n '
405- 'stderr:\n '
406- '{}\n '
407- .format (self ._proc .returncode , out , err ))
398+ raise subprocess .CalledProcessError (
399+ self ._proc .returncode , self ._proc .args , out , err )
408400
409401 @classmethod
410402 def bin_path (cls ):
@@ -511,17 +503,11 @@ def grab_frame(self, **savefig_kwargs):
511503 '''
512504 # Overloaded to explicitly close temp file.
513505 _log .debug ('MovieWriter.grab_frame: Grabbing frame.' )
514- try :
515- # Tell the figure to save its data to the sink, using the
516- # frame format and dpi.
517- with self ._frame_sink () as myframesink :
518- self .fig .savefig (myframesink , format = self .frame_format ,
519- dpi = self .dpi , ** savefig_kwargs )
520-
521- except RuntimeError :
522- out , err = self ._proc .communicate ()
523- _log .info ('MovieWriter -- Error running proc:\n %s\n %s' , out , err )
524- raise
506+ # Tell the figure to save its data to the sink, using the
507+ # frame format and dpi.
508+ with self ._frame_sink () as myframesink :
509+ self .fig .savefig (myframesink , format = self .frame_format ,
510+ dpi = self .dpi , ** savefig_kwargs )
525511
526512 def finish (self ):
527513 # Call run here now that all frame grabbing is done. All temp files
0 commit comments