Unfortunately, I can't seem to get any exceptions written to the file. This technique is still useful though.
Using this technique I peppered my code with
with open("/home/eggswithcheese/WSU-PAL-PPC/mysite/tmp/mylog.txt", "a") as f:
f.write("program has reached such-and-such section \n")
Which at least allowed me to figure out where it's crashing, which has now confused me even more.
In my index view I have this line:
return redirect(url_for("primary_production"))
Which should result in the program executing this:
@app.route('/primary_production', methods=['GET', 'POST'])
@app.route('/primary_production.html', methods=['GET', 'POST'])
def primary_production():
'''
Renders the primary_production template, which shows calculated values and a button to download them.
'''
with open("/home/eggswithcheese/WSU-PAL-PPC/mysite/tmp/mylog.txt", "a") as f:
f.write("in primary production view \n")
try:
with open("/home/eggswithcheese/WSU-PAL-PPC/mysite/tmp/mylog.txt", "a") as f:
f.write("trying to render template of primary_production.html \n")
return render_template("primary_production.html")
except Exception as e:
with open("/home/eggswithcheese/WSU-PAL-PPC/mysite/tmp/mylog.txt", "a") as f:
f.write("Caught exception {}\n".format(e))
print str(e)
return render_template(INTERNAL_SERVER_ERROR_TEMPLATE_ROUTE, error = str(e))
But the program somehow never gets there. The line "in primary production view" never gets written to the file! Why would it crash in between views?