From 2065cb1badd48eeef307b40b25ec4d38cd1cefc7 Mon Sep 17 00:00:00 2001 From: Tim Kuhlman Date: Mon, 30 Jun 2014 13:52:20 -0600 Subject: [PATCH] Moved code out of __init__.py, minor pep8 fix --- mon_notification/notification_exceptions.py | 1 + mon_notification/processors/__init__.py | 15 +---------- mon_notification/processors/base.py | 29 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 mon_notification/processors/base.py diff --git a/mon_notification/notification_exceptions.py b/mon_notification/notification_exceptions.py index 4bfa9a6..e7b2a3d 100644 --- a/mon_notification/notification_exceptions.py +++ b/mon_notification/notification_exceptions.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + class NotificationException(Exception): """Base exception class. """ diff --git a/mon_notification/processors/__init__.py b/mon_notification/processors/__init__.py index 993e4d1..4800332 100644 --- a/mon_notification/processors/__init__.py +++ b/mon_notification/processors/__init__.py @@ -13,17 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging - -log = logging.getLogger(__name__) - - -class BaseProcessor(object): - @staticmethod - def _add_to_queue(queue, queue_name, msg): - """Warns on full queue then does a blocking push to the queue. - """ - if queue.full(): - log.warn('Queue %s is full, publishing is blocked' % queue_name) - queue.put(msg) - log.debug("Put message %s on queue %s" % (msg, queue_name)) +from base import BaseProcessor diff --git a/mon_notification/processors/base.py b/mon_notification/processors/base.py new file mode 100644 index 0000000..993e4d1 --- /dev/null +++ b/mon_notification/processors/base.py @@ -0,0 +1,29 @@ +# Copyright (c) 2014 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +log = logging.getLogger(__name__) + + +class BaseProcessor(object): + @staticmethod + def _add_to_queue(queue, queue_name, msg): + """Warns on full queue then does a blocking push to the queue. + """ + if queue.full(): + log.warn('Queue %s is full, publishing is blocked' % queue_name) + queue.put(msg) + log.debug("Put message %s on queue %s" % (msg, queue_name))