Fixed some pep8 and pylint issues.
This commit is contained in:
		@@ -13,8 +13,6 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import sys
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
from nova import flags
 | 
					from nova import flags
 | 
				
			||||||
from nova import log as logging
 | 
					from nova import log as logging
 | 
				
			||||||
from nova import utils
 | 
					from nova import utils
 | 
				
			||||||
@@ -30,13 +28,14 @@ LOG = logging.getLogger('nova.notifier.list_notifier')
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
drivers = None
 | 
					drivers = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ImportFailureNotifier(object):
 | 
					class ImportFailureNotifier(object):
 | 
				
			||||||
    """Noisily re-raises some exception over-and-over when notify is called."""
 | 
					    """Noisily re-raises some exception over-and-over when notify is called."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, exception):
 | 
					    def __init__(self, exception):
 | 
				
			||||||
        self.exception = exception
 | 
					        self.exception = exception
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def notify(message):
 | 
					    def notify(self, message):
 | 
				
			||||||
        raise self.exception
 | 
					        raise self.exception
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -52,6 +51,7 @@ def _get_drivers():
 | 
				
			|||||||
                drivers.append(ImportFailureNotifier(e))
 | 
					                drivers.append(ImportFailureNotifier(e))
 | 
				
			||||||
    return drivers
 | 
					    return drivers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def notify(message):
 | 
					def notify(message):
 | 
				
			||||||
    """Passes notification to mulitple notifiers in a list."""
 | 
					    """Passes notification to mulitple notifiers in a list."""
 | 
				
			||||||
    for driver in _get_drivers():
 | 
					    for driver in _get_drivers():
 | 
				
			||||||
@@ -61,6 +61,7 @@ def notify(message):
 | 
				
			|||||||
            LOG.exception(_("Problem '%(e)s' attempting to send to "
 | 
					            LOG.exception(_("Problem '%(e)s' attempting to send to "
 | 
				
			||||||
                            "notification driver %(driver)s." % locals()))
 | 
					                            "notification driver %(driver)s." % locals()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def _reset_drivers():
 | 
					def _reset_drivers():
 | 
				
			||||||
    """Used by unit tests to reset the drivers."""
 | 
					    """Used by unit tests to reset the drivers."""
 | 
				
			||||||
    global drivers
 | 
					    global drivers
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,19 +34,25 @@ class NotifierListTestCase(test.TestCase):
 | 
				
			|||||||
        list_notifier._reset_drivers()
 | 
					        list_notifier._reset_drivers()
 | 
				
			||||||
        self.stubs = stubout.StubOutForTesting()
 | 
					        self.stubs = stubout.StubOutForTesting()
 | 
				
			||||||
        # Mock log to add one to exception_count when log.exception is called
 | 
					        # Mock log to add one to exception_count when log.exception is called
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def mock_exception(cls, *args):
 | 
					        def mock_exception(cls, *args):
 | 
				
			||||||
            self.exception_count += 1
 | 
					            self.exception_count += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.exception_count = 0
 | 
					        self.exception_count = 0
 | 
				
			||||||
        list_notifier_log = logging.getLogger('nova.notifier.list_notifier')
 | 
					        list_notifier_log = logging.getLogger('nova.notifier.list_notifier')
 | 
				
			||||||
        self.stubs.Set(list_notifier_log, "exception", mock_exception)
 | 
					        self.stubs.Set(list_notifier_log, "exception", mock_exception)
 | 
				
			||||||
        # Mock no_op notifier to add one to notify_count when called.
 | 
					        # Mock no_op notifier to add one to notify_count when called.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def mock_notify(cls, *args):
 | 
					        def mock_notify(cls, *args):
 | 
				
			||||||
            self.notify_count += 1
 | 
					            self.notify_count += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.notify_count = 0
 | 
					        self.notify_count = 0
 | 
				
			||||||
        self.stubs.Set(nova.notifier.no_op_notifier, 'notify', mock_notify)
 | 
					        self.stubs.Set(nova.notifier.no_op_notifier, 'notify', mock_notify)
 | 
				
			||||||
        # Mock log_notifier to raise RuntimeError when called.
 | 
					        # Mock log_notifier to raise RuntimeError when called.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def mock_notify2(cls, *args):
 | 
					        def mock_notify2(cls, *args):
 | 
				
			||||||
            raise RuntimeError("Bad notifier.")
 | 
					            raise RuntimeError("Bad notifier.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.stubs.Set(nova.notifier.log_notifier, 'notify', mock_notify2)
 | 
					        self.stubs.Set(nova.notifier.log_notifier, 'notify', mock_notify2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def tearDown(self):
 | 
					    def tearDown(self):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user