netconf.py 文件源码

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

项目:pathman-sr 作者: CiscoDevNet 项目源码 文件源码
def post_xml(url, data):
    '''request post'''
    headers = {'Content-type': 'application/xml'}
    auth = (controller['any_user'], controller['any_pass'])
    try:
        response =  requests.post(url, data=data, auth=auth, headers=headers, verify=False)
        logging.info("Url POST Status: %s" % response.status_code)
        if response.status_code in [200, 204]:
            if len(response.text) > 0:
                return True, response.json()
            else:
                return True, {}
        else:
            return False, str(response.text)
    except requests.exceptions.ConnectionError, e:
        logging.error('Connection Error: %s' % e.message)
        return False, str(e.message)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号