From 7bb8d5873933fc58427e95d0e15ed9a3f46d0035 Mon Sep 17 00:00:00 2001 From: Sergio Santoro Date: Thu, 18 Feb 2016 14:44:21 +0100 Subject: [PATCH] Use environment variables for configuration --- README.md | 10 +++++----- bin/srv.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d1ed24f..3283af0 100644 --- a/README.md +++ b/README.md @@ -106,12 +106,12 @@ The `City` parameter in `~/.wegorc` is ignored. ### Configure wttr.in -Edit the `bin/srv.py` and specify the path to the local `wttr.in` installation, -to the GeoLite database and to the `wego` installation: +Configure the following environment variables specifing the path to the local `wttr.in` +installation, to the GeoLite database and to the `wego` installation. For example: - MYDIR = "/home/igor/wttr.in" - GEOLITE = "/home/igor/wttr.in/GeoLite2-City.mmdb" - WEGO = "/home/igor/go/bin/wego" + WTTR_MYDIR = "/home/igor/wttr.in" + WTTR_GEOLITE = "/home/igor/wttr.in/GeoLite2-City.mmdb" + WTTR_WEGO = "/home/igor/go/bin/wego" ### Configure HTTP-frontend service diff --git a/bin/srv.py b/bin/srv.py index 357753f..94d9ef0 100644 --- a/bin/srv.py +++ b/bin/srv.py @@ -22,9 +22,9 @@ patch_all() from flask import Flask, request, render_template, send_from_directory app = Flask(__name__) -MYDIR = os.path.abspath(os.path.dirname( os.path.dirname('__file__') )) -GEOLITE = os.path.join( MYDIR, "GeoLite2-City.mmdb" ) -WEGO = "/home/igor/go/bin/wego" +MYDIR = os.environ.get('WTTR_MYDIR', os.path.abspath(os.path.dirname( os.path.dirname('__file__') ))) +GEOLITE = os.environ.get('WTTR_GEOLITE', os.path.join( MYDIR, "GeoLite2-City.mmdb" )) +WEGO = os.environ.get('WTTR_WEGO', "/home/igor/go/bin/wego") CACHEDIR = os.path.join( MYDIR, "cache" ) IP2LCACHE = os.path.join( MYDIR, "cache/ip2l" )