python与代理的JIRA连接

时间:2015-06-16 16:04:47

标签: python jira basic-authentication python-jira

我尝试使用代理通过python-jira进行连接:

server = {"server": "https://ip:port/jira",
          'proxies': {"http": "http://ip:port", "https": "http://ip:port"},
          'verify': False,
          'stream': True}

cls.jira_object = JIRA(options=server,
                       basic_auth=(user, password),
                       validate=True)

回溯错误:

tests\jira_test\ticket_test.py:52: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
build\bdist.win-amd64\egg\jira\client.py:217: in __init__
    ???
build\bdist.win-amd64\egg\jira\client.py:1841: in session
    ???
build\bdist.win-amd64\egg\jira\utils.py:78: in json_loads
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

r = None, verb = '???', kwargs = {}, request = None, headers = None

>   ???
E   JIRAError: JiraError HTTP None

知道如何让jira-python与代理连接吗?

4 个答案:

答案 0 :(得分:2)

您可以为JIRA的构造函数提供代理:

cls.jira_object = JIRA(options=server,
                       basic_auth=(user, password),
                       validate=True,
                       proxies={"http": "http://ip:port", "https": "http://ip:port"})

请记住从您的选项dict中删除“代理”

有关构造函数的更多信息: https://github.com/pycontribs/jira/blob/develop/jira/client.py

答案 1 :(得分:0)

这在python3中对我有用。

server =  {'server': 'https://<jira.url.com>','proxies':"http://%s:%s@<ip>:<port>"%(proxy_user,proxy_password),'verify':True}

jira_object = JIRA(options=server,basic_auth=(jira_user,jira_password),                     validate=True)

另一种选择:

import os
from jira import JIRA 

os.environ['https_proxy']='<proxy url>:<port>'
os.environ['http_proxy']='<proxy url>:<port>'
con = JIRA(basic_auth=(<username>,<password>),options={'server':'<jira_url>'})

答案 2 :(得分:0)

最简单的方法是设置“ HTTPS_PROXY”环境变量。 我是这样做的:

import os
os.environ["HTTPS_PROXY"]="https://genproxy:8080"
os.environ["HTTP_PROXY"]="http://ip:port"

答案 3 :(得分:-1)

它似乎需要一点魔力。 Have a look here at this answer.

这是代码:

my_jira = JIRA(jira_options, basic_auth=(jira_admin, jira_passwd))
my_jjira._session.proxies = {'http': '127.0.0.1:8888', 'https': '127.0.0.1:8888' }