From ae2ac674921afd3311eee853b6491437de8ead27 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 11 2017 06:23:18 +0000 Subject: make systemd.journal dependency unconditional Right now pylint will barf on the import if it's not available. We might as well just require it unconditionally. --- diff --git a/waiverdb.spec b/waiverdb.spec index 7c00315..e89d041 100644 --- a/waiverdb.spec +++ b/waiverdb.spec @@ -16,6 +16,11 @@ BuildRequires: python-sqlalchemy BuildRequires: python-flask-restful BuildRequires: python-flask-sqlalchemy BuildRequires: python-kerberos +%if 0%{?rhel} <= 7 +BuildRequires: systemd-python +%else +BuildRequires: python2-systemd +%endif BuildRequires: pytest BuildRequires: python-mock BuildRequires: pytest @@ -29,6 +34,11 @@ Requires: python-sqlalchemy Requires: python-flask-restful Requires: python-flask-sqlalchemy Requires: python-kerberos +%if 0%{?rhel} <= 7 +Requires: systemd-python +%else +Requires: python2-systemd +%endif Requires: python-mock Requires: fedmsg Requires: python-flask-oidc diff --git a/waiverdb/logger.py b/waiverdb/logger.py index 58932f3..49e0c1a 100644 --- a/waiverdb/logger.py +++ b/waiverdb/logger.py @@ -11,6 +11,7 @@ import logging import sys +import systemd.journal def log_to_stdout(app, level=logging.INFO): @@ -24,10 +25,6 @@ def log_to_stdout(app, level=logging.INFO): def log_to_journal(app, level=logging.INFO): - try: - import systemd.journal - except: - raise ValueError("systemd.journal module is not installed") journal_handler = systemd.journal.JournalHandler() journal_handler.setLevel(level) app.logger.addHandler(journal_handler)