From 21ad6ecffb3a74191fb582f649424540d9c2012a Mon Sep 17 00:00:00 2001 From: Philip Sargent <philip.sargent@klebos.com> Date: Thu, 30 Dec 2021 22:46:34 +0000 Subject: [PATCH] New debug page for subprocess runs --- core/views/expo.py | 11 +++++--- templates/errors/debug.html | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 templates/errors/debug.html diff --git a/core/views/expo.py b/core/views/expo.py index 6c79771..8b3e27e 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -318,12 +318,17 @@ def editexpopage(request, path): # see also core/models/cave.py writetrogglefile() f.write(result) # should replace .call with .run and capture_output=True - subprocess.call([git, "add", filename], cwd=cwd) - subprocess.call([git, "commit", "-m", 'Edit this page'], cwd=cwd) except PermissionError: message = f'CANNOT save this file.\nPERMISSIONS incorrectly set on server for this file {filename}. Ask a nerd to fix this.' return render(request,'errors/generic.html', {'message': message}) - except SubprocessError: + + try: + cp1 = subprocess.run([git, "add", filename], cwd=cwd, capture_output=True) + cp2 = subprocess.run([git, "commit", "-m", 'Edit this page'], cwd=cwd, capture_output=True) + message = f'Test output this file {filename}. git command output.\n' + str(cp1) + '\n\n' + str(cp2) + return render(request,'errors/debug.html', {'message': message}) + + except subprocess.SubprocessError: message = f'CANNOT git on server for this file {filename}. Edits not saved.\nAsk a nerd to fix this.' return render(request,'errors/generic.html', {'message': message}) diff --git a/templates/errors/debug.html b/templates/errors/debug.html new file mode 100644 index 0000000..c2cc025 --- /dev/null +++ b/templates/errors/debug.html @@ -0,0 +1,50 @@ +{% extends 'base.html' %} + +{% block title %}Troggle Debug - Generic page{% endblock %} +{% block content %} + +<div class='middle'> + <h2>Troggle Debug Page</h2> +</div> + + +<div class='middle3 login'> + <div class='space'></div> + <div class='align-center'> + <h3>This is temporary debugging output. There has NOT been an error.</h3> + <h4> + + <font color="red"> + {% if message %} + <pre> + {{message}} + </pre> + {% else %} + <p>Placeholder. </p> + + {% endif %} + </font> + </h4> + <div class='space'><p> </div> + + <h3>What you should do now</h3> + <p>Please report this by emailing the nerds at + <a href="mailto:expo-tech@lists.wookware.org">expo-tech@lists.wookware.org</a> with this information: + <ol> + <li>The message written in <font color="red">red</font> above. + <li>The previous page URL: <font color="red"> +<script type="text/javascript"> + document.write(document.referrer); +</script></font> + <li>Go back to this previous page <script type="text/javascript"> + document.write("<a href='",document.referrer,"'>",document.referrer,"</a>"); + </script> + and see if you can tell whether the page causing the debug output was in HTML text which had been written manually, or whether it appeared to be a programming intention. + </ol> + + + </div> +</div> +</div> + +{% endblock %} \ No newline at end of file