1

为此绞尽脑汁。刚刚在这里注册,因为我在这方面遇到了很多麻烦。这是我的超级简单代码:

from jira.client import JIRA
jira_user='username'
jira_pass='password' 
jira_server='https://jira-01:8443'

jira_options = {'server': jira_server, 'verify': False}
jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_pass))

执行时,我得到这个:

    Traceback (most recent call last):
 File "jira1.py", line 12, in <module>
 jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_pass))
 File "/usr/lib/python2.6/site-packages/jira/client.py", line 219, in __init__  
si = self.server_info()
File "/usr/lib/python2.6/site-packages/jira/client.py", line 1504, in server_info
return self._get_json('serverInfo')
  File "/usr/lib/python2.6/site-packages/jira/client.py", line 1894, in _get_json
  r = self._session.get(url, params=params)
  File "/usr/lib/python2.6/site-packages/jira/resilientsession.py", line 78, in get
return self.__verb('GET', url, **kwargs)
  File "/usr/lib/python2.6/site-packages/jira/resilientsession.py", line 63, in __verb
r = method(url, **kwargs)
 File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 477, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
 File "/usr/lib/python2.6/site-packages/requests/adapters.py", line 370, in send
timeout=timeout
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn
conn.connect()
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
 File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 279, in ssl_wrap_socket
 cnx.set_tlsext_host_name(server_hostname)
AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'

如果我删除也会发生同样的事情'verify': False

我知道我可以访问 API 并且该用户具有权限,因为我可以使用 curl 正确地点击它并获得正确的结果。

任何帮助表示赞赏。

4

1 回答 1

0

通过 yum 重新安装 python-requests 解决。

于 2015-05-12T13:00:07.373 回答