Decorator

Since the script can often fail, it’s convenient to have a notification. The fail decorator attends to catch any exception and send a notification threw the notificator.

Fail Decorator

notif.fail_decorator.notification_on_fail(notificator, verbose_level=3)[source]

Decorator to wrap a function to track if the script fail and push notification to a previously set notif. Mostly inspire from the Fabric 1.1 wrapper.

Parameters
  • notificator (Notificator) – The notif to push notification threw.

  • verbose_level (int) or (str) – The verbose level of the notification message, 1 been the lesser and 3 the maximum

  • verbosity. (of) –

Returns

A wrapped function which will catch if an error occur and send a notification through the notificator.

Example

notif = SlackNotificator(url="webhook_url")

@notification_on_fail(notificator=notif, verbose_level='2')
def fail_test():
    print(t)

Notificator & Sacred

Unfortunately, the fail decorator is not working with the package (yet) with the Sacred package.