Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44fe937

Browse filesBrowse files
anntzertimhoffm
authored andcommitted
Slightly rework animation logging. (#13161)
- Only log ffmpeg stdout/stderr if it outputted something on that stream. This avoids a spurious empty stdout log when the entire interesting part is on stderr. - Improve the writer-fallback logic (right now the IndexError clause is never going to be executed as the IndexError is first raised (if writers.list() is empty) in the log.warning call, before the try: ...).
1 parent 6a6f21c commit 44fe937
Copy full SHA for 44fe937

File tree

Expand file treeCollapse file tree

1 file changed

+16
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-14
lines changed

‎lib/matplotlib/animation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/animation.py
+16-14Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,14 @@ def cleanup(self):
387387
# Use the encoding/errors that universal_newlines would use.
388388
out = TextIOWrapper(BytesIO(out)).read()
389389
err = TextIOWrapper(BytesIO(err)).read()
390-
_log.log(
391-
logging.WARNING if self._proc.returncode else logging.DEBUG,
392-
"MovieWriter stdout:\n%s", out)
393-
_log.log(
394-
logging.WARNING if self._proc.returncode else logging.DEBUG,
395-
"MovieWriter stderr:\n%s", err)
390+
if out:
391+
_log.log(
392+
logging.WARNING if self._proc.returncode else logging.DEBUG,
393+
"MovieWriter stdout:\n%s", out)
394+
if err:
395+
_log.log(
396+
logging.WARNING if self._proc.returncode else logging.DEBUG,
397+
"MovieWriter stderr:\n%s", err)
396398
if self._proc.returncode:
397399
raise subprocess.CalledProcessError(
398400
self._proc.returncode, self._proc.args, out, err)
@@ -1085,14 +1087,14 @@ class to use, such as 'ffmpeg'. If ``None``, defaults to
10851087
extra_args=extra_args,
10861088
metadata=metadata)
10871089
else:
1088-
_log.warning("MovieWriter {} unavailable. Trying to use {} "
1089-
"instead.".format(writer, writers.list()[0]))
1090-
1091-
try:
1092-
writer = writers[writers.list()[0]](fps, codec, bitrate,
1093-
extra_args=extra_args,
1094-
metadata=metadata)
1095-
except IndexError:
1090+
if writers.list():
1091+
alt_writer = writers[writers.list()[0]]
1092+
_log.warning("MovieWriter %s unavailable; trying to use "
1093+
"%s instead.", writer, alt_writer)
1094+
writer = alt_writer(
1095+
fps, codec, bitrate,
1096+
extra_args=extra_args, metadata=metadata)
1097+
else:
10961098
raise ValueError("Cannot save animation: no writers are "
10971099
"available. Please install ffmpeg to "
10981100
"save animations.")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.