]> rtime.felk.cvut.cz Git - coffee/coffee-flask.git/commitdiff
Change the name of the configuration file
authorMichal Sojka <michal.sojka@cvut.cz>
Wed, 27 Feb 2019 15:26:54 +0000 (16:26 +0100)
committerMichal Sojka <michal.sojka@cvut.cz>
Wed, 27 Feb 2019 15:40:58 +0000 (16:40 +0100)
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
app.py

index 7b25ae264d0818a70f8ce8eaa001940ec5a0dc9a..173b4cf3121cd4428f639a6b3c8cecf1ba48ff7a 100644 (file)
@@ -1,2 +1,3 @@
 __pycache__
 coffee.db
+.coffee.conf
diff --git a/app.py b/app.py
index 63ee2b5311b37e8827cecacb72459ea97b5983ca..ef9075b629a104c895f2a2eaa6363faa8343c122 100644 (file)
--- 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)