From 918d9dc1453b21d2d0aff6c4b3e91d2c25faa072 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Wed, 27 Feb 2019 16:26:54 +0100 Subject: [PATCH 1/1] Change the name of the configuration file MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The reason for this is that the Apache mod_wsgi sets the current directory of WSGI processes to $HOME and on our server $HOME/.config is a directory. Instead of changing the working directory of WSGI processes (which I don't know how to configure), I prefer to use a different (non-colliding) file name: .coffee.conf. Having the configuration file outside of the source directory has the advantage that running "git clean -fx" in that directory does not delete the configuration, which cannot be easily recovered (our Slack history is limited). --- .gitignore | 1 + app.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7b25ae2..173b4cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ coffee.db +.coffee.conf diff --git a/app.py b/app.py index 63ee2b5..ef9075b 100644 --- a/app.py +++ b/app.py @@ -197,10 +197,10 @@ def tell_coffeebot(): if request.method == "POST": what = loads(request.data.decode("utf-8")) try: - with open(".config", "r") as f: + with open(".coffee.conf", "r") as f: conf = loads(f.read()) except: - return "Config read error: '%s'! Please find in git history how the .config should look." \ + return "Config read error: '%s'! Please find in git history how the .coffee.conf file should look." \ % sys.exc_info()[1] try: res = post(conf["coffeebot"]["url"], json=what) -- 2.39.2