Commit 88d6a924 authored by Michael Murtaugh's avatar Michael Murtaugh

display error message when make fails

parent f4951ad7
......@@ -23,14 +23,18 @@ async def is_makeable (path, cwd=".", makefile="makefile"):
async def make (path, cwd=".", makefile="makefile"):
rpath = os.path.relpath(path, cwd)
p = await create_subprocess_exec("make", "-f", makefile, rpath, stdout = PIPE, stderr = STDOUT, cwd = cwd)
# while True:
# line = await p.stdout.readline()
resp = ""
while True:
line = await p.stdout.readline()
if not line:
# log(line)
# print (line)
ret = await p.wait() == 0
print ("make {0}: {1}".format(path, ret), file=sys.stderr)
await log("make {0}: {1}".format(path, ret))
return ret
return (ret, resp)
textchars = bytearray({7,8,9,10,12,13,27} | set(range(0x20, 0x100)) - {0x7f})
is_binary_string = lambda bytes: bool(bytes.translate(None, textchars))
......@@ -158,7 +162,18 @@ async def route_get (request):
if path == '':
path = '.'
if path and await is_makeable(path,['makefile']):
await make(path,['makefile'])
code, resp = await make(path,['makefile'])
if not code:
resppage = """<!DOCTYPE html>
<meta charset="utf-8">
<p>An error occuring making the file {0}. Here's the output:</p>
</html>""".format(path, resp)
return web.Response(text=resppage, content_type="text/html")
if os.path.exists(path):
if os.path.isdir(path):
if 'application/json' in request.headers.get("Accept") or 'json' in request.rel_url.query:
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