Skip to content

Commit

Permalink
topotato: don't hard-fail on graphviz issues
Browse files Browse the repository at this point in the history
`dot` being either unavailable or not producing output was just wrecking
topotato pretty hard.  Handle this a bit more gracefully...

Signed-off-by: David Lamparter <[email protected]>
  • Loading branch information
eqvinox committed Sep 17, 2024
1 parent aaef6ad commit f0ee9c9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions topotato/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def __init__(self, prettysession, instance):

_filename_sub = re.compile(r"[^a-zA-Z0-9]")

# pylint: disable=too-many-locals,protected-access,possibly-unused-variable,too-many-statements
# pylint: disable=too-many-locals,protected-access,possibly-unused-variable,too-many-statements,too-many-branches
def report(self):
topotatocls = self[0].item.getparent(base.TopotatoClass)
nodeid = topotatocls.nodeid
Expand Down Expand Up @@ -249,8 +249,15 @@ def report(self):

# remove doctype / xml / ... decls
ElementTree.register_namespace("", "http://www.w3.org/2000/svg")
toposvg = ElementTree.fromstring(self[0].toposvg)
toposvg = ElementTree.tostring(toposvg).decode("UTF-8")
try:
toposvgp = ElementTree.fromstring(self[0].toposvg)
toposvg = ElementTree.tostring(toposvgp).decode("UTF-8")
except ElementTree.ParseError as e:
_logger.error(
"failed to process graphviz network diagram SVG as XML: %r", e
)
_logger.error("SVG data: %r", self[0].toposvg)
toposvg = ""

data["timed"] = items[-1]._jsdata
if items[-1]._pdml:
Expand Down Expand Up @@ -430,7 +437,7 @@ def files(self):
self, "dotfilesvg", ".svg", "image/svg+xml", self.toposvg
)
else:
self.toposvg = None
self.toposvg = b""


class PrettyShutdown(PrettyTopotato, matches=base.InstanceShutdown):
Expand Down

0 comments on commit f0ee9c9

Please sign in to comment.