Commit af2e46bc authored by Tom Niget's avatar Tom Niget Committed by Tom Niget

demo: handle errors in topology generation

parent e7fe543a
...@@ -499,11 +499,12 @@ if args.port: ...@@ -499,11 +499,12 @@ if args.port:
if page < 2: if page < 2:
body = route_svg(page) body = route_svg(page)
else: else:
body = registry.Popen(('python3', '-c', r"""if 1: out, err = registry.Popen(('python3', '-c', r"""if 1:
import math, json import math, json, sys
from re6st.registry import RegistryClient from re6st.registry import RegistryClient
g = json.loads(RegistryClient( topo = RegistryClient('http://localhost/').topology()
'http://localhost/').topology()) g = json.loads(topo)
assert g, 'Topology is empty'
r = set(g.pop('', ())) r = set(g.pop('', ()))
a = set() a = set()
for v in g.values(): for v in g.values():
...@@ -522,7 +523,11 @@ if args.port: ...@@ -522,7 +523,11 @@ if args.port:
for v in v: for v in v:
print('"%s" -> "%s";' % (n, title(v))) print('"%s" -> "%s";' % (n, title(v)))
print('}') print('}')
"""), stdout=subprocess.PIPE, cwd="..").communicate()[0].decode("utf-8") """), stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd="..").communicate()
if err:
self.send_error(500, explain=err.decode("utf-8"))
return
body = out.decode("utf-8")
if body: if body:
body = subprocess.Popen(('neato', '-Tsvg'), body = subprocess.Popen(('neato', '-Tsvg'),
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment