diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-10 21:38:39 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-10 21:38:39 +0100 |
commit | 7651560a2d075e7f68d2323d88cec52af873d6fc (patch) | |
tree | 44774deefec4e6c1fdf2fd7fea14d4403f2d97ad /newspipe | |
parent | fixed issues reported by flake8. (diff) | |
download | newspipe-7651560a2d075e7f68d2323d88cec52af873d6fc.tar.gz newspipe-7651560a2d075e7f68d2323d88cec52af873d6fc.tar.bz2 newspipe-7651560a2d075e7f68d2323d88cec52af873d6fc.zip |
added a way to specify a configuration file via an environment variable
Diffstat (limited to 'newspipe')
-rw-r--r-- | newspipe/bootstrap.py | 10 | ||||
-rw-r--r-- | newspipe/lib/data.py | 1 |
2 files changed, 5 insertions, 6 deletions
diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py index 1fdb32e2..2aa39895 100644 --- a/newspipe/bootstrap.py +++ b/newspipe/bootstrap.py @@ -53,21 +53,19 @@ if os.environ.get("Newspipe_TESTING", False) == "true": application.debug = logging.DEBUG application.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:" application.config["TESTING"] = True +elif os.environ.get("Newspipe_CONFIG", False): + # if the configuration file is specified via an environment variable + application.config.from_pyfile(os.environ.get("Newspipe_CONFIG"), silent=False) else: try: application.config.from_pyfile("development.py", silent=False) except Exception: application.config.from_pyfile("production.py", silent=False) -# scheme, domain, _, _, _ = urlsplit(conf.PLATFORM_URL) -# application.config["SERVER_NAME"] = domain -# application.config["PREFERRED_URL_SCHEME"] = scheme - set_logging(application.config["LOG_PATH"]) db = SQLAlchemy(application) - babel = Babel(application) @@ -80,4 +78,4 @@ def get_locale(): # otherwise try to guess the language from the user accept # header the browser transmits. We support de/fr/en in this # example. The best match wins. - return request.accept_languages.best_match(["fr", "en"]) + return request.accept_languages.best_match(application.config["LANGUAGES"].keys()) diff --git a/newspipe/lib/data.py b/newspipe/lib/data.py index 5e9457b7..89f6bca6 100644 --- a/newspipe/lib/data.py +++ b/newspipe/lib/data.py @@ -44,6 +44,7 @@ from newspipe.controllers import BookmarkController, BookmarkTagController logger = logging.getLogger(__name__) + def import_opml(nickname, opml_content): """ Import new feeds from an OPML file. |