def notify(t):
    """Decorates a fabric task"""
    @wraps(t)
    def wrapper(*args, **kwargs):
        start = time.time()
        error = None
        output = None
        try:
            r = t(*args, **kwargs)
            if r:
                if not isinstance(r, list):
                    r = [r]
                output = '\n\n'.join(['%s\n%s\n%s' %
                    (res.command, res.stdout, res.stderr) for res in r]
                )
        except Exception as e:
            error = e

        end = time.time()
        duration = start - end
        try:
            dog_http_api.event(_title(t, args, kwargs, error),
                               _text(t, args, kwargs, duration, output, error),
                               source_type_name="fabric",
                               alert_type="error" if error else "success",
                               priority="normal",
                               aggregation_key=_aggregation_key(t, args, kwargs, error),
                               tags=_tags(t, args, kwargs, error))
        except Exception as e:
            logger.warn("Datadog notification on task {0} failed with {1}".format(t.__name__, e))

        if error:
            raise error
        else:
            return r

    return WrappedCallableTask(wrapper)
dataset/ETHPy150Open DataDog/dogapi/src/dogapi/fab.py/notify/swapped operands of `-`