| 253 | |
| 254 | @classmethod |
| 255 | def _run_checked_subprocess(cls, command, tex, *, cwd=None): |
| 256 | _log.debug(cbook._pformat_subprocess(command)) |
| 257 | try: |
| 258 | report = subprocess.check_output( |
| 259 | command, cwd=cwd if cwd is not None else cls._cache_dir, |
| 260 | stderr=subprocess.STDOUT) |
| 261 | except subprocess.CalledProcessError as exc: |
| 262 | raise RuntimeError( |
| 263 | '{prog} was not able to process the following string:\n' |
| 264 | '{tex!r}\n\n' |
| 265 | 'Here is the full command invocation and its output:\n\n' |
| 266 | '{format_command}\n\n' |
| 267 | '{exc}\n\n'.format( |
| 268 | prog=command[0], |
| 269 | format_command=cbook._pformat_subprocess(command), |
| 270 | tex=tex.encode('unicode_escape'), |
| 271 | exc=exc.output.decode('utf-8', 'backslashreplace')) |
| 272 | ) from None |
| 273 | except (FileNotFoundError, OSError) as exc: |
| 274 | raise RuntimeError( |
| 275 | f'Failed to process string with tex because {command[0]} ' |
| 276 | 'could not be found') from exc |
| 277 | _log.debug(report) |
| 278 | return report |
| 279 | |
| 280 | @classmethod |
| 281 | def make_dvi(cls, tex, fontsize): |