Commit 7d436aba authored by Michael Murtaugh's avatar Michael Murtaugh

limited console output

parent 857bb67f
...@@ -3,7 +3,7 @@ import sys, os, asyncio, json ...@@ -3,7 +3,7 @@ import sys, os, asyncio, json
from asyncio import create_subprocess_exec from asyncio import create_subprocess_exec
from urllib.parse import urlparse, unquote as urlunquote, quote as urlquote from urllib.parse import urlparse, unquote as urlunquote, quote as urlquote
import argparse import argparse
from asyncio.subprocess import DEVNULL
""" """
Todo: use proper http error responses for errors, see aiohttp/http_exceptions.py Todo: use proper http error responses for errors, see aiohttp/http_exceptions.py
...@@ -11,7 +11,7 @@ Todo: use proper http error responses for errors, see aiohttp/http_exceptions.py ...@@ -11,7 +11,7 @@ Todo: use proper http error responses for errors, see aiohttp/http_exceptions.py
async def is_makeable (path, cwd=".", makefile="makefile"): async def is_makeable (path, cwd=".", makefile="makefile"):
rpath = os.path.relpath(path, cwd) rpath = os.path.relpath(path, cwd)
p = await create_subprocess_exec("make", "--question", "-f", makefile, rpath, cwd = cwd) p = await create_subprocess_exec("make", "--question", "-f", makefile, rpath, cwd = cwd, stdout=DEVNULL, stderr=DEVNULL)
# retcode 0=file is up to date, 1=file needs remaking, 2=file is not makeable # retcode 0=file is up to date, 1=file needs remaking, 2=file is not makeable
ret = await p.wait() == 1 ret = await p.wait() == 1
# print (f"is_makeable {path}: {ret}", file=sys.stderr) # print (f"is_makeable {path}: {ret}", file=sys.stderr)
...@@ -37,7 +37,7 @@ def is_binary_file (p): ...@@ -37,7 +37,7 @@ def is_binary_file (p):
def editable (path): def editable (path):
_, ext = os.path.splitext(path) _, ext = os.path.splitext(path)
ext = ext.lower()[1:] ext = ext.lower()[1:]
print (f"editable? ext {ext}", file=sys.stderr) # print (f"editable? ext {ext}", file=sys.stderr)
return ((ext not in ("html", "htm")) and not is_binary_file(path)) return ((ext not in ("html", "htm")) and not is_binary_file(path))
# From aiohttp/web_urldispatcher.py # From aiohttp/web_urldispatcher.py
...@@ -92,7 +92,7 @@ def directory_as_html(filepath, directory, prefix, editor_url=None): ...@@ -92,7 +92,7 @@ def directory_as_html(filepath, directory, prefix, editor_url=None):
async def route_get (request): async def route_get (request):
# return FileResponse(filepath, chunk_size=self._chunk_size) # return FileResponse(filepath, chunk_size=self._chunk_size)
path = urlunquote(urlparse(request.rel_url.raw_path.lstrip("/")).path) path = urlunquote(urlparse(request.rel_url.raw_path.lstrip("/")).path)
print ("route_get", path, file=sys.stderr) print ("GET", path, file=sys.stderr)
if path == '': if path == '':
path = '.' path = '.'
if path and await is_makeable(path, makefile=request.app['makefile']): if path and await is_makeable(path, makefile=request.app['makefile']):
...@@ -108,7 +108,7 @@ async def route_get (request): ...@@ -108,7 +108,7 @@ async def route_get (request):
async def route_post (request): async def route_post (request):
""" write posted text value to file """ """ write posted text value to file """
path = urlunquote(urlparse(request.rel_url.raw_path.lstrip("/")).path) path = urlunquote(urlparse(request.rel_url.raw_path.lstrip("/")).path)
print ("route_post", path, file=sys.stderr) print ("POST", path, file=sys.stderr)
if os.path.exists(path) and os.path.isfile(path): if os.path.exists(path) and os.path.isfile(path):
data = await request.post() data = await request.post()
if 'text' in data: if 'text' in data:
......
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