python: report dot errors

* python/spot/aux.py: Catch errors from dot and signal them.
* tests/python/_aux.ipynb: New file.
* tests/Makefile.am: Add it.
* tests/sanity/ipynb.pl: Support the convention that tests starting with
'_' should not be published on the web site.
This commit is contained in:
Alexandre Duret-Lutz 2016-02-16 14:34:57 +01:00
parent c093b7b78f
commit 22af7aefdf
4 changed files with 86 additions and 5 deletions

View file

@ -23,6 +23,7 @@ Auxiliary functions for Spot's Python bindings
from functools import lru_cache
import subprocess
import sys
def extend(*classes):
@ -50,9 +51,16 @@ def str_to_svg(str):
"""
dot = subprocess.Popen(['dot', '-Tsvg'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
res = dot.communicate(str)
return res[0].decode('utf-8')
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = dot.communicate(str)
if stderr:
print("Calling 'dot' for the conversion to SVG produced the message:\n"
+ stderr.decode('utf-8'), file=sys.stderr)
ret = dot.wait()
if ret:
raise subprocess.CalledProcessError(ret, 'dot')
return stdout.decode('utf-8')
def ostream_to_svg(ostr):