Make Airbrake/Errbit support optional

This commit is contained in:
Midgard 2020-07-17 11:06:27 +02:00
parent d904f3c562
commit fd5b432837
Signed by: midgard
GPG key ID: 511C112F1331BBB4
4 changed files with 16 additions and 9 deletions

View file

@ -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
)

View file

@ -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}"

View file

@ -3,7 +3,6 @@ Flask-Login
Flask-Bootstrap
Flask-SQLAlchemy
Flask-DebugToolbar
airbrake
Flask-WTF
Flask-OAuthlib
Flask-Admin

View file

@ -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