]> git.datanom.net - pwp.git/blobdiff - run.py
Half way through migration away from sqlalchemy
[pwp.git] / run.py
diff --git a/run.py b/run.py
index ea7ae15a9a4b207c25cdbeef067fe08c9331eccc..1812f4850b48d00c29ef366fcc26d2fae800ca08 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -1,5 +1,33 @@
 #!flask/bin/python
 from app import app
-app.jinja_env.auto_reload = True
-app.config['TEMPLATES_AUTO_RELOAD'] = True
-app.run(debug=True)
+from config import ADMINS, MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD
+import logging
+
+app.debug = True
+
+if not app.debug:
+    from logging.handlers import SMTPHandler, RotatingFileHandler
+    credentials = None
+    if MAIL_USERNAME or MAIL_PASSWORD:
+        credentials = (MAIL_USERNAME, MAIL_PASSWORD)
+    mail_handler = SMTPHandler((MAIL_SERVER, MAIL_PORT), 'no-reply@' + MAIL_SERVER, ADMINS, 'PWP failure', credentials)
+    mail_handler.setLevel(logging.ERROR)
+    mail_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
+    app.logger.addHandler(mail_handler)
+
+    file_handler = RotatingFileHandler('log/pwp.log', 'a', 1 * 1024 * 1024, 10)
+    file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
+    app.logger.addHandler(file_handler)
+    file_handler.setLevel(logging.DEBUG)
+else:
+#    from flask_debugtoolbar import DebugToolbarExtension
+    
+#    toolbar = DebugToolbarExtension(app)
+    app.jinja_env.auto_reload = True
+    app.config['TEMPLATES_AUTO_RELOAD'] = True
+
+app.logger.setLevel(logging.DEBUG)
+app.logger.info('pwp startup')
+#from werkzeug.security import generate_password_hash
+#print (generate_password_hash('test', method='sha256'))
+app.run()
This page took 0.044417 seconds and 5 git commands to generate.