From fd5b432837790a0ef31c8c67b92a760533d8c229 Mon Sep 17 00:00:00 2001 From: Midgard Date: Fri, 17 Jul 2020 11:06:27 +0200 Subject: [PATCH] Make Airbrake/Errbit support optional --- app/app.py | 11 ++++++----- first-setup.sh | 10 +++++++++- requirements.in | 1 - requirements.txt | 3 +-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/app.py b/app/app.py index 91e52bb..8ae89ee 100755 --- a/app/app.py +++ b/app/app.py @@ -44,16 +44,17 @@ def register_plugins(app: Flask) -> Manager: if airbrake is None: raise Exception( "Airbrake support was requested (AIRBRAKE_ID is present in config), " - "but could not import airbrake. Make sure it's installed" + "but could not import airbrake. Make sure `airbrake` is installed" ) airbrakelogger = logging.getLogger("airbrake") # Airbrake - airbrake = airbrake.Airbrake(project_id=app.config["AIRBRAKE_ID"], - api_key=app.config["AIRBRAKE_KEY"]) - # ugly hack to make this work for out errbit - airbrake._api_url = "http://errbit.awesomepeople.tv/api/v3/projects/{}/notices".format( # pylint: disable=W0212 + airbrake = airbrake.Airbrake( + project_id=app.config["AIRBRAKE_ID"], api_key=app.config["AIRBRAKE_KEY"] + ) + # Change URL in a hacky way to make this work for our errbit + airbrake._api_url = "http://errbit.awesomepeople.tv/api/v3/projects/{}/notices".format( # pylint: disable=protected-access airbrake.project_id ) diff --git a/first-setup.sh b/first-setup.sh index d419c44..868db65 100755 --- a/first-setup.sh +++ b/first-setup.sh @@ -22,6 +22,14 @@ pip install pip-tools echo -e "${B} Downloading dependencies ${E}" pip-sync +echo -en "${B} Do you want to install support for the Airbrake API for error logging? If you don't have an Errbit server or Airbrake account, answer no. (y/N) ${E}" +read confirm +if [ "$confirm" = y ]; then + pip install airbrake +else + echo "Not installing airbrake" +fi + echo -e "${B} Copying config template. All custom config options can be set in the config.py file ${E}" cd app cp config.example.py config.py @@ -30,4 +38,4 @@ cd .. echo -e "${B} Seeding database ${E}" ./populate-db.sh -echo -e "${B} Activate your venv using 'source venv/bin/activate'.\nThen run the server with 'python app/app.py runserver' ${E}" +echo -e "${B} Activate your venv using 'source venv/bin/activate'.\nThen run the development server with 'python app/app.py runserver' ${E}" diff --git a/requirements.in b/requirements.in index 8c56874..6bd107f 100644 --- a/requirements.in +++ b/requirements.in @@ -3,7 +3,6 @@ Flask-Login Flask-Bootstrap Flask-SQLAlchemy Flask-DebugToolbar -airbrake Flask-WTF Flask-OAuthlib Flask-Admin diff --git a/requirements.txt b/requirements.txt index 88dd801..5c0337c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,6 @@ # # pip-compile # -airbrake==2.1.2 alembic==1.0.8 # via flask-migrate appdirs==1.4.3 # via black attrs==19.1.0 # via black @@ -37,7 +36,7 @@ python-editor==1.0.4 # via alembic pyyaml==5.3 regex==2020.1.8 # via black requests-oauthlib==1.1.0 # via flask-oauthlib -requests==2.21.0 # via airbrake, requests-oauthlib +requests==2.21.0 # via requests-oauthlib six==1.12.0 # via python-dateutil sqlalchemy==1.3.2 # via alembic, flask-sqlalchemy tatsu==4.4.0