Decorator

Since script can often fail, it’s convenient to have a notification. The fail decorator attend 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 now catch if an error occur and throw a notification threw the notif.

Example

notif = SlackNotificator(url="webhook_url")

@notification_on_fail(notif=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.