From 192eefb641967557f9fbab84f38fdad4cbc49c3e Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Thu, 29 Oct 2020 10:10:13 -0400 Subject: [PATCH] Squash 'Cannot find qpid python module' warnings from Moksha Importing moksha causes a 'Cannot find qpid python module' warning if it's not installed, but we don't need the QPid support. --- module_build_service/__init__.py | 2 ++ module_build_service/log_workaround.py | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 module_build_service/log_workaround.py diff --git a/module_build_service/__init__.py b/module_build_service/__init__.py index 292ffa67..85fd587a 100644 --- a/module_build_service/__init__.py +++ b/module_build_service/__init__.py @@ -26,6 +26,8 @@ from flask import Flask, has_app_context, url_for from flask_sqlalchemy import SQLAlchemy from sqlalchemy.pool import StaticPool +# Filter out warnings we don't want from external modules +import module_build_service.log_workaround # noqa: F401 from module_build_service.common.config import config_section from module_build_service.web.proxy import ReverseProxy diff --git a/module_build_service/log_workaround.py b/module_build_service/log_workaround.py new file mode 100644 index 00000000..bb502e51 --- /dev/null +++ b/module_build_service/log_workaround.py @@ -0,0 +1,9 @@ +import logging + + +class QpidWarningFilter(logging.Filter): + def filter(self, record): + return "Cannot find qpid python module" not in record.getMessage() + + +logging.getLogger("moksha.hub").addFilter(QpidWarningFilter())