diff options
author | Francois Chollet <fchollet@google.com> | 2017-04-19 13:29:41 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-04-19 14:48:28 -0700 |
commit | 1fc916d0c16eab89523b1e031854313ab1ba18e2 (patch) | |
tree | 1502bfcc9f7d5d17d5c309f0db317c8587d0501c /tensorflow/contrib/keras | |
parent | d017a797c4d5247c0ebdfb04227ac431e3923472 (diff) |
Silence a call to `print` that occurs in case of pydot import error.
Change: 153634770
Diffstat (limited to 'tensorflow/contrib/keras')
-rw-r--r-- | tensorflow/contrib/keras/python/keras/utils/vis_utils.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tensorflow/contrib/keras/python/keras/utils/vis_utils.py b/tensorflow/contrib/keras/python/keras/utils/vis_utils.py index 49efa6040d..9e2ee86424 100644 --- a/tensorflow/contrib/keras/python/keras/utils/vis_utils.py +++ b/tensorflow/contrib/keras/python/keras/utils/vis_utils.py @@ -18,17 +18,24 @@ from __future__ import division from __future__ import print_function import os - +import sys try: # pydot-ng is a fork of pydot that is better maintained. import pydot_ng as pydot # pylint: disable=g-import-not-at-top except ImportError: # Fall back on pydot if necessary. + # Silence a `print` statement that occurs in case of import error, + # by temporarily replacing sys.stdout. + _stdout = sys.stdout + sys.stdout = sys.stderr try: import pydot # pylint: disable=g-import-not-at-top except ImportError: pydot = None + finally: + # Restore sys.stdout. + sys.stdout = _stdout def _check_pydot(): |