diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-03-01 16:48:06 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-03-01 16:48:06 +0900 |
commit | 18bb86a27f9cc66925116984c668b44f6cbfa2d7 (patch) | |
tree | d5cd84e15480b1006631fa09f04fc472b853c24f /setup.py | |
parent | 6bce06757fe6b81aebb34eb5f4a6a4b2bf7ba1f3 (diff) | |
download | sphinx-git-18bb86a27f9cc66925116984c668b44f6cbfa2d7.tar.gz |
Catch errors on compiling catalogs (refs: #4655)
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -3,6 +3,7 @@ import os import sys from distutils import log from distutils.cmd import Command +from io import StringIO from setuptools import find_packages, setup @@ -64,6 +65,20 @@ extras_require = { cmdclass = {} + +class Tee(object): + def __init__(self, stream): + self.stream = stream + self.buffer = StringIO() + + def write(self, s): + self.stream.write(s) + self.buffer.write(s) + + def flush(self): + self.stream.flush() + + try: from babel.messages.pofile import read_po from babel.messages.frontend import compile_catalog @@ -81,7 +96,13 @@ else: """ def run(self): - compile_catalog.run(self) + try: + sys.stderr = Tee(sys.stderr) + compile_catalog.run(self) + finally: + if sys.stderr.buffer.getvalue(): + print("Compiling failed.") + sys.exit(1) if isinstance(self.domain, list): for domain in self.domain: |