Compare commits

...
2 Commits
Author SHA1 Message Date
mxmehl ef9cc1aab3 fix pylint and black 2021-12-23 13:57:13 +01:00
mxmehl 0a3fc13f1e minor service improvements 2021-12-23 13:56:58 +01:00
3 changed files with 17 additions and 11 deletions
+4
View File
@@ -5,11 +5,13 @@
git:
repo: https://src.mehl.mx/mxmehl/autoreply-editor.git
dest: autoreply-editor
notify: restart supervisord
- name: Deploy config file
template:
src: config.py.j2
dest: autoreply-editor/config.py
notify: restart supervisord
- name: Install specified python requirements
pip:
@@ -46,3 +48,5 @@
- name: update supervisord
command: supervisorctl update
listen: reload supervisord
- name: restart supervisord
command: supervisorctl restart autoreply-editor
+1 -1
View File
@@ -1,4 +1,4 @@
[program:autoreply-editor]
directory=/home/{{ ansible_user_id }}/autoreply-editor
command=gunicorn --bind 0.0.0.0:{{ port }} wsgi:app
startsecs=60
startsecs=5
+12 -10
View File
@@ -51,7 +51,9 @@ def qmail_status(user):
def check_user(user):
"""Check if user exists"""
fulluser = [item for item in app.config.get("USERS") if item[1].split('@')[0] == user]
fulluser = [
item for item in app.config.get("USERS") if item[1].split("@")[0] == user
]
if not fulluser:
return False
else:
@@ -123,6 +125,7 @@ def index():
users=app.config.get("USERS"),
)
@app.route("/user/<user>")
def user_status(user):
"""Status for specific user"""
@@ -130,9 +133,7 @@ def user_status(user):
if not check_user(user):
abort(404)
with open(
get_messagefile(user), "r", encoding="utf-8"
) as messagefile:
with open(get_messagefile(user), "r", encoding="utf-8") as messagefile:
message = messagefile.read()
return render_template(
@@ -151,9 +152,7 @@ def user_update(user):
if request.form["action"] == "message":
input_message = request.form["message"]
with open(
get_messagefile(user), "w", encoding="utf-8"
) as messagefile:
with open(get_messagefile(user), "w", encoding="utf-8") as messagefile:
messagefile.write(str(input_message))
result = "Success: The autoreply message has been updated!"
@@ -182,9 +181,12 @@ def user_update(user):
try:
return render_template("update.html", user=user, result=result)
except UnboundLocalError:
return render_template("update.html", user=user, result="Something went terribly wrong!")
return render_template(
"update.html", user=user, result="Something went terribly wrong!"
)
@app.errorhandler(404)
def page_not_found(e):
return render_template('error.html', error=e), 404
def page_not_found(error):
"""Error for 404"""
return render_template("error.html", error=error), 404