From 53c4c6d6864f08036a9e169fe165986b6305c8d6 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 26 Feb 2020 15:15:33 +0100 Subject: Removed Flask-SSLify and Heroku default support. --- newspipe/bootstrap.py | 2 -- newspipe/conf.py | 30 +++++------------------------- newspipe/notifications/emails.py | 8 ++------ newspipe/runserver.py | 3 --- newspipe/web/templates/about_more.html | 3 +-- newspipe/web/templates/layout.html | 2 +- newspipe/web/views/home.py | 3 +-- newspipe/web/views/views.py | 2 -- poetry.lock | 16 +--------------- pyproject.toml | 1 - 10 files changed, 11 insertions(+), 59 deletions(-) diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py index 8e5413e0..004bebf0 100644 --- a/newspipe/bootstrap.py +++ b/newspipe/bootstrap.py @@ -15,8 +15,6 @@ def set_logging(log_path=None, log_level=logging.INFO, modules=(), if not modules: modules = ('root', 'bootstrap', 'runserver', 'web', 'crawler.default_crawler', 'manager', 'plugins') - if conf.ON_HEROKU: - log_format = '%(levelname)s %(message)s' if log_path: if not os.path.exists(os.path.dirname(log_path)): os.makedirs(os.path.dirname(log_path)) diff --git a/newspipe/conf.py b/newspipe/conf.py index ced602ca..96445b24 100644 --- a/newspipe/conf.py +++ b/newspipe/conf.py @@ -4,6 +4,7 @@ This file contain the variables used by the application. """ +import configparser as confparser import os import logging @@ -22,7 +23,6 @@ TIME_ZONE = { "fr": "Europe/Paris" } -ON_HEROKU = int(os.environ.get('HEROKU', 0)) == 1 DEFAULTS = {"platform_url": "https://www.newspipe.org/", "self_registration": "false", "cdn_address": "", @@ -47,27 +47,10 @@ DEFAULTS = {"platform_url": "https://www.newspipe.org/", "feed_refresh_interval": "120" } -if not ON_HEROKU: - import configparser as confparser - # load the configuration - config = confparser.SafeConfigParser(defaults=DEFAULTS) - config.read(os.path.join(BASE_DIR, "conf/conf.cfg")) -else: - class Config(object): - def get(self, _, name): - return os.environ.get(name.upper(), DEFAULTS.get(name)) - def getint(self, _, name): - return int(self.get(_, name)) - - def getboolean(self, _, name): - value = self.get(_, name) - if value == 'true': - return True - elif value == 'false': - return False - return None - config = Config() +# load the configuration +config = confparser.SafeConfigParser(defaults=DEFAULTS) +config.read(os.path.join(BASE_DIR, "conf/conf.cfg")) WEBSERVER_HOST = config.get('webserver', 'host') @@ -88,10 +71,7 @@ try: TOKEN_VALIDITY_PERIOD = config.getint('misc', 'token_validity_period') except: TOKEN_VALIDITY_PERIOD = int(config.get('misc', 'token_validity_period')) -if not ON_HEROKU: - LOG_PATH = os.path.abspath(config.get('misc', 'log_path')) -else: - LOG_PATH = '' +LOG_PATH = os.path.abspath(config.get('misc', 'log_path')) LOG_LEVEL = {'debug': logging.DEBUG, 'info': logging.INFO, 'warn': logging.WARN, diff --git a/newspipe/notifications/emails.py b/newspipe/notifications/emails.py index 098c29bf..e1f2c272 100644 --- a/newspipe/notifications/emails.py +++ b/newspipe/notifications/emails.py @@ -46,13 +46,9 @@ def send_async_email(mfrom, mto, msg): def send(*args, **kwargs): """ - This functions enables to send email through SendGrid - or a SMTP server. + This functions enables to send email via different method. """ - if conf.ON_HEROKU: - send_sendgrid(**kwargs) - else: - send_smtp(**kwargs) + send_smtp(**kwargs) def send_smtp(to="", bcc="", subject="", plaintext="", html=""): """ diff --git a/newspipe/runserver.py b/newspipe/runserver.py index 287a52f8..a1ebb54c 100755 --- a/newspipe/runserver.py +++ b/newspipe/runserver.py @@ -22,9 +22,6 @@ import calendar from bootstrap import conf, application, populate_g from flask_babel import Babel, format_datetime -if conf.ON_HEROKU: - from flask_sslify import SSLify - SSLify(application, subdomains=True) babel = Babel(application) diff --git a/newspipe/web/templates/about_more.html b/newspipe/web/templates/about_more.html index d4353a15..3b253b25 100644 --- a/newspipe/web/templates/about_more.html +++ b/newspipe/web/templates/about_more.html @@ -2,8 +2,7 @@ {% block content %}