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).
__pycache__
coffee.db
+.coffee.conf
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)