예제 #1
0
        def wrapped(self, context, *args, **kw):
            # Don't store self or context in the payload, it now seems to
            # contain confidential information.
            try:
                return f(self, context, *args, **kw)
            except Exception as e:
                with excutils.save_and_reraise_exception():
                    if notifier:
                        call_dict = safe_utils.getcallargs(f, *args, **kw)
                        payload = dict(exception=e,
                                       private=dict(args=call_dict))

                        # Use a temp vars so we don't shadow
                        # our outer definitions.
                        temp_level = level
                        if not temp_level:
                            temp_level = notifier.ERROR

                        temp_type = event_type
                        if not temp_type:
                            # If f has multiple decorators, they must use
                            # functools.wraps to ensure the name is
                            # propagated.
                            temp_type = f.__name__

                        notifier.notify(context, publisher_id, temp_type,
                                        temp_level, payload)
예제 #2
0
        def wrapped(self, context, *args, **kw):
            # Don't store self or context in the payload, it now seems to
            # contain confidential information.
            try:
                return f(self, context, *args, **kw)
            except Exception as e:
                with excutils.save_and_reraise_exception():
                    if notifier:
                        call_dict = safe_utils.getcallargs(f, *args, **kw)
                        payload = dict(exception=e,
                                       private=dict(args=call_dict)
                                       )

                        # Use a temp vars so we don't shadow
                        # our outer definitions.
                        temp_level = level
                        if not temp_level:
                            temp_level = notifier.ERROR

                        temp_type = event_type
                        if not temp_type:
                            # If f has multiple decorators, they must use
                            # functools.wraps to ensure the name is
                            # propagated.
                            temp_type = f.__name__

                        notifier.notify(context, publisher_id, temp_type,
                                        temp_level, payload)
예제 #3
0
 def test_partial_mixed_args(self):
     args = (3,)
     kwargs = {'instance': {'uuid': 1}}
     callargs = safe_utils.getcallargs(self._test_func, *args, **kwargs)
     self.assertEqual(4, len(callargs))
     self.assertIn('instance', callargs)
     self.assertEqual({'uuid': 1}, callargs['instance'])
     self.assertIn('red', callargs)
     self.assertEqual(3, callargs['red'])
     self.assertIn('blue', callargs)
     self.assertIsNone(callargs['blue'])
예제 #4
0
 def test_partial_args(self):
     args = ({'uuid': 1}, 3)
     kwargs = {}
     callargs = safe_utils.getcallargs(self._test_func, *args, **kwargs)
     # implicit self counts as an arg
     self.assertEqual(4, len(callargs))
     self.assertIn('instance', callargs)
     self.assertEqual({'uuid': 1}, callargs['instance'])
     self.assertIn('red', callargs)
     self.assertEqual(3, callargs['red'])
     self.assertIn('blue', callargs)
     self.assertIsNone(callargs['blue'])
예제 #5
0
 def test_all_kwargs(self):
     args = ()
     kwargs = {'instance': {'uuid': 1}, 'red': 3, 'blue': 4}
     callargs = safe_utils.getcallargs(self._test_func, *args, **kwargs)
     # implicit self counts as an arg
     self.assertEqual(4, len(callargs))
     self.assertIn('instance', callargs)
     self.assertEqual({'uuid': 1}, callargs['instance'])
     self.assertIn('red', callargs)
     self.assertEqual(3, callargs['red'])
     self.assertIn('blue', callargs)
     self.assertEqual(4, callargs['blue'])
예제 #6
0
        def wrapped(self, context, *args, **kw):
            # Don't store self or context in the payload, it now seems to
            # contain confidential information.
            try:
                return f(self, context, *args, **kw)
            except Exception as e:
                with excutils.save_and_reraise_exception():
                    if notifier:
                        call_dict = safe_utils.getcallargs(f, context, *args, **kw)
                        payload = dict(exception=e, private=dict(args=call_dict))

                        temp_type = event_type
                        if not temp_type:
                            # If f has multiple decorators, they must use
                            # functools.wraps to ensure the name is
                            # propagated.
                            temp_type = f.__name__

                        notifier.error(context, temp_type, payload)
예제 #7
0
        def wrapped(self, context, *args, **kw):
            # Don't store self or context in the payload, it now seems to
            # contain confidential information.
            try:
                return f(self, context, *args, **kw)
            except Exception as e:
                with excutils.save_and_reraise_exception():
                    if notifier:
                        call_dict = safe_utils.getcallargs(
                            f, context, *args, **kw)
                        payload = dict(exception=e,
                                       private=dict(args=call_dict))

                        temp_type = event_type
                        if not temp_type:
                            # If f has multiple decorators, they must use
                            # functools.wraps to ensure the name is
                            # propagated.
                            temp_type = f.__name__

                        notifier.error(context, temp_type, payload)