diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 354873b351c3..f8cd5aeef5f0 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -247,10 +247,11 @@ def isAvailable(cls): running the commandline tool. ''' try: - subprocess.Popen(cls.bin_path(), + p = subprocess.Popen(cls.bin_path(), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p.communicate() return True except OSError: return False @@ -326,6 +327,30 @@ def _frame_sink(self): # because it will no longer be referenced and will be gc-ed. return open(fname, 'wb') + def grab_frame(self, **savefig_kwargs): + ''' + Grab the image information from the figure and save as a movie frame. + All keyword arguments in savefig_kwargs are passed on to the 'savefig' + command that saves the figure. + ''' + #Overloaded to explicitly close temp file. + verbose.report('MovieWriter.grab_frame: Grabbing frame.', + level='debug') + try: + # Tell the figure to save its data to the sink, using the + # frame format and dpi. + myframesink = self._frame_sink() + self.fig.savefig(myframesink, format=self.frame_format, + dpi=self.dpi, **savefig_kwargs) + myframesink.close() + + except RuntimeError: + out, err = self._proc.communicate() + verbose.report('MovieWriter -- Error ' + 'running proc:\n%s\n%s' % (out, + err), level='helpful') + raise + def finish(self): # Call run here now that all frame grabbing is done. All temp files # are available to be assembled. diff --git a/lib/matplotlib/tests/test_animation.py b/lib/matplotlib/tests/test_animation.py index 9da8f81de6c3..29fc30250321 100644 --- a/lib/matplotlib/tests/test_animation.py +++ b/lib/matplotlib/tests/test_animation.py @@ -62,6 +62,8 @@ def animate(i): raise KnownFailureTest("There can be errors in the numpy " + "import stack, " + "see issues #1891 and #2679") + finally: + F.close() @cleanup