def onProgress(node, kwargs={}): res = { 'eta': context.root.eta, 'gone': context.root.gone, 'total': context.root.total } if context.root else {} res.update(kwargs) saveOps(opsPath) if hasattr(node, 'name'): res['stage'] = node.name res['stageProgress'] = node.gone res['stageTotal'] = node.total context.notifier.send(res)
def g(*args, **kwargs): try: res = {'result': f(*args, **kwargs)} code = 200 saveOps(opsPath, True) if verbose: log.info(getInfo(f, args)) except Exception: info = getInfo(f, args) log.exception(info) res = {'result': 'Fail', 'call': info, 'exception': format_exc()} code = 400 context.notifier.send(res) finally: clean() return res, code