url.py 文件源码

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

项目:DevOps 作者: YoLoveLife 项目源码 文件源码
def run(self, terms, variables=None, **kwargs):

        validate_certs = kwargs.get('validate_certs', True)

        ret = []
        for term in terms:
            display.vvvv("url lookup connecting to %s" % term)
            try:
                response = open_url(term, validate_certs=validate_certs)
            except HTTPError as e:
                raise AnsibleError("Received HTTP error for %s : %s" % (term, str(e)))
            except URLError as e:
                raise AnsibleError("Failed lookup url for %s : %s" % (term, str(e)))
            except SSLValidationError as e:
                raise AnsibleError("Error validating the server's certificate for %s: %s" % (term, str(e)))
            except ConnectionError as e:
                raise AnsibleError("Error connecting to %s: %s" % (term, str(e)))

            for line in response.read().splitlines():
                ret.append(to_text(line))
        return ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号