使用Python-Jira获取JIRA上的错误状态

时间:2017-06-14 04:11:05

标签: python python-2.7 jira jira-rest-api python-jira

我正在尝试编写一个脚本来获取JIRA上的错误状态,

import jira.client
from jira.client import JIRA

options = {'server': 'https://<url>:<port>/', 'verify': 'path/to/id_rsa.pub'}
jira = JIRA(options, basic_auth=('username', 'pswd'))

但是收到以下警告信息且无法连接:

bash-4.2$ python try_jira.py
WARNING:root:unknown error (_ssl.c:2747) while doing GET https://spg-jira.xpliant.com:8443/rest/api/2/serverInfo [{u'headers': {'Accept-Encoding': 'gzip, deflate', u'Accept': u'application/json,*.*;q=0.9', 'User-Agent': 'python-requests/2.17.3', 'Connection': 'keep-alive', u'X-Atlassian-Token': u'no-check', u'Cache-Control': u'no-cache', u'Content-Type': u'application/json'}, 'params': None}]
WARNING:root:Got ConnectionError [unknown error (_ssl.c:2747)] errno:None on GET https://spg-jira.xpliant.com:8443/rest/api/2/serverInfo
{'request': <PreparedRequest [GET]>, 'response': None}\{'request': <PreparedRequest [GET]>, 'response': None}
WARNING:root:Got recoverable error from GET https://spg-jira.xpliant.com:8443/rest/api/2/serverInfo, will retry [1/3] in 7.55620272034s. Err: unknown error (_ssl.c:2747)
WARNING:root:unknown error (_ssl.c:2747) while doing GET https://spg-jira.xpliant.com:8443/rest/api/2/serverInfo [{u'headers': {'Accept-Encoding': 'gzip, deflate', u'Accept': u'application/json,*.*;q=0.9', 'User-Agent': 'python-requests/2.17.3', 'Connection': 'keep-alive', u'X-Atlassian-Token': u'no-check', u'Cache-Control': u'no-cache', u'Content-Type': u'application/json'}, 'params': None}]
WARNING:root:Got ConnectionError [unknown error (_ssl.c:2747)] errno:None on GET https://spg-jira.xpliant.com:8443/rest/api/2/serverInfo
{'request': <PreparedRequest [GET]>, 'response': None}\{'request': <PreparedRequest [GET]>, 'response': None}
WARNING:root:Got recoverable error from GET https://spg-jira.xpliant.com:8443/rest/api/2/serverInfo, will retry [2/3] in 8.41708571146s. Err: unknown error (_ssl.c:2747)
WARNING:root:unknown error (_ssl.c:2747) while doing GET https://spg-jira.xpliant.com:8443/rest/api/2/serverInfo [{u'headers': {'Accept-Encoding': 'gzip, deflate', u'Accept': u'application/json,*.*;q=0.9', 'User-Agent': 'python-requests/2.17.3', 'Connection': 'keep-alive', u'X-Atlassian-Token': u'no-check', u'Cache-Control': u'no-cache', u'Content-Type': u'application/json'}, 'params': None}]
WARNING:root:Got ConnectionError [unknown error (_ssl.c:2747)] errno:None on GET https://spg-jira.xpliant.com:8443/rest/api/2/serverInfo
{'request': <PreparedRequest [GET]>, 'response': None}\{'request': <PreparedRequest [GET]>, 'response': None}
WARNING:root:Got recoverable error from GET https://spg-jira.xpliant.com:8443/rest/api/2/serverInfo, will retry [3/3] in 39.7347032392s. Err: unknown error (_ssl.c:2747)

如果我在选项中保留'verify' : False,我会看到以下消息:

bash-4.2$ python try_jira.py
/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)

有人可以帮我弄清楚我在这里遗失了什么吗?

1 个答案:

答案 0 :(得分:0)

文档说:

  

强烈建议不要使用未经验证的HTTPS请求   你了解风险并希望禁用这些警告,你可以   使用disable_warnings():

>>> import urllib3
>>> urllib3.disable_warnings()

因此,如果您了解其含义,可以将disable_warnings调用放入代码中。