diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | app.py | 35 | ||||
-rw-r--r-- | config.py.sample | 1 | ||||
-rw-r--r-- | tests/config_test.py | 1 |
4 files changed, 23 insertions, 18 deletions
@@ -54,6 +54,10 @@ Or if you have disabled registration, use the ``` flask createuser ``` command t pip install waitress + # If you want SENTRY support (also add related things in config) + pip install sentry-sdk[flask] + + Copy systemd services files ```docs/reel2bits-*.service``` to ```/etc/systemd/system/``` and adapt them to your setup. systemctl enable reel2bits-web reel2bits-worker @@ -36,17 +36,24 @@ __VERSION__ = VERSION AVAILABLE_LOCALES = ["fr", "fr_FR", "en", "en_US", "pl"] try: - from raven.contrib.flask import Sentry - import raven + import sentry_sdk + from sentry_sdk.integrations.flask import FlaskIntegration as SentryFlaskIntegration + from sentry_sdk.integrations.celery import CeleryIntegration as SentryCeleryIntegration - print(" * Sentry support loaded") + print(" * Sentry Flask/Celery support have been loaded") HAS_SENTRY = True except ImportError: - print(" * No Sentry support") + print(" * No Sentry Flask/Celery support available") HAS_SENTRY = False mail = Mail() +GIT_VERSION = "" +gitpath = os.path.join(os.getcwd(), ".git") +if os.path.isdir(gitpath): + GIT_VERSION = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) + if GIT_VERSION: + GIT_VERSION = GIT_VERSION.strip().decode("UTF-8") def make_celery(remoulade): celery = Celery(remoulade.import_name, broker=remoulade.config["CELERY_BROKER_URL"]) @@ -78,9 +85,12 @@ def create_app(config_filename="config.py", app_name=None, register_blueprints=T app.jinja_env.globals.update(duration_song_human=duration_song_human) if HAS_SENTRY: - app.config["SENTRY_RELEASE"] = raven.fetch_git_sha(os.path.dirname(__file__)) - sentry = Sentry(app, dsn=app.config["SENTRY_DSN"]) # noqa: F841 - print(" * Sentry support activated") + sentry_sdk.init( + app.config["SENTRY_DSN"], + integrations=[SentryFlaskIntegration(), SentryCeleryIntegration()], + release=f"{VERSION} ({GIT_VERSION})" + ) + print(" * Sentry Flask/Celery support activated") print(" * Sentry DSN: %s" % app.config["SENTRY_DSN"]) if app.config["DEBUG"] is True: @@ -136,13 +146,6 @@ def create_app(config_filename="config.py", app_name=None, register_blueprints=T db.session.add(actor) db.session.commit() - git_version = "" - gitpath = os.path.join(os.getcwd(), ".git") - if os.path.isdir(gitpath): - git_version = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) - if git_version: - git_version = git_version.strip().decode("UTF-8") - @babel.localeselector def get_locale(): # if a user is logged in, use the locale from the user settings @@ -169,8 +172,8 @@ def create_app(config_filename="config.py", app_name=None, register_blueprints=T cfg = { "REEL2BITS_VERSION_VER": VERSION, - "REEL2BITS_VERSION_GIT": git_version, - "REEL2BITS_VERSION": "{0} ({1})".format(VERSION, git_version), + "REEL2BITS_VERSION_GIT": GIT_VERSION, + "REEL2BITS_VERSION": "{0} ({1})".format(VERSION, GIT_VERSION), "app_name": _config.app_name, "app_description": _config.app_description, } diff --git a/config.py.sample b/config.py.sample index 6d159595..ac9666b4 100644 --- a/config.py.sample +++ b/config.py.sample @@ -10,7 +10,6 @@ TEMP_DOWNLOAD_FOLDER = "/home/reel2bits/tmp" AUDIOWAVEFORM_BIN = "/usr/local/bin/audiowaveform" # If using sentry, set a DSN -SENTRY_USER_ATTRS = ['name', 'email'] SENTRY_DSN = "" # Redis configuration for broker, used for async background tasks diff --git a/tests/config_test.py b/tests/config_test.py index c01d0d32..504ab2ef 100644 --- a/tests/config_test.py +++ b/tests/config_test.py @@ -47,7 +47,6 @@ TEMP_DOWNLOAD_FOLDER = "/home/dashie/dev/reel2bits/tmp" AUDIOWAVEFORM_BIN = "/usr/local/bin/audiowaveform" # Sentry -SENTRY_USER_ATTRS = ["name", "email"] SENTRY_DSN = "" # Bcrypt algorithm hashing rounds (reduced for testing purposes only!) |