executor.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:forge 作者: datawire 项目源码 文件源码
def report(self, autocolor=True):
        total = 0
        errors = []
        for r in self.traversal:
            total += 1
            if r.is_leaf_error():
                exc = r.exception[1]
                indent = "  "
                if getattr(exc, "report_traceback", True):
                    tb = "\n\n" + r.get_traceback().strip()
                    errors.append("%s%s: unexpected error%s" % (indent, r.executor.name,
                                                                tb.replace("\n", "\n  " + indent)))
                else:
                    errors.append("%s%s: %s" % (indent, r.executor.context, exc))

        if autocolor:
            if errors:
                color = self.terminal.bold_red
            else:
                color = self.terminal.green
        else:
            color = lambda x: x

        result = "\n".join(["%s tasks run, %s errors" % (total, len(errors))] + errors)

        return "\n".join([color(line) for line in result.splitlines()])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号