undefinedVar.py 文件源码

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

项目:lint-playbook 作者: host-anshu 项目源码 文件源码
def queue_exc(*arg, **kw):  # pylint: disable=W0613
    """Queue undefined variable exception"""
    _self = arg[0]
    if not isinstance(_self, AnsibleUndefinedVariable):
        # Run for AnsibleUndefinedVariable instance
        return
    _rslt_q = None
    for stack_trace in inspect.stack():
        # Check if method to be skipped
        if stack_trace[3] in SKIP_METHODS:
            continue
        _frame = stack_trace[0]
        _locals = inspect.getargvalues(_frame).locals
        if 'self' not in _locals:
            continue
        # Check if current frame instance of worker
        if isinstance(_locals['self'], WorkerProcess):
            # Get queue to add exception
            _rslt_q = getattr(_locals['self'], '_rslt_q')
    if not _rslt_q:
        raise ValueError("No Queue found.")
    _rslt_q.put({"undefined_var": arg[3].message}, interceptor=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号