from jira.client import JIRA
import requests
import jira.exceptions
import json
import re
class MyJira(JIRA):
def _create_http_basic_session(self, username, password):
url = self._options['server'] + '/rest/auth/1/session'
payload = {
'username': username,
'password': password
}
verify = False
self._session = requests.session(verify=verify,
hooks={'args': self._add_content_type})
r = self._session.post(url, data=json.dumps(payload))
jira.exceptions.raise_on_error(r)
options = {'server':'http://localhost:8080',
'verify': False}
username = 'usrName'
password = 'passWord'
basic_auth =(username,password)
jira = MyJira(options, basic_auth)
issue_dict = {
'project':{'key':'PROJKEY'},
'summary': 'New Issue from jira-python',
'description': 'Test Description for new issue created from jira-python',
'issueType': {'name': 'Bug'}}
new_issue = jira.create_issue(fields=issue_dict,preftech=True)
print new_issue.id
这产生了我这个错误堆栈跟踪/日志
/home/ve/bin/python/home/PycharmProjects/RestJira/restjira.py
Traceback (most recent call last):
File "/home/PycharmProjects/RestJira/myrestjira.py", line 81, in <module>
new_issue = jira.create_issue(fields=issue_dict,preftech=True)
File "/home/ve/lib/python2.6/site-packages/jira/client.py", line 369, in create_issue
raise_on_error(r)
File "/home/ve/lib/python2.6/site-packages/jira/exceptions.py", line 29, in raise_on_error
error = errorMessages[0]
IndexError: list index out of range
我究竟做错了什么?我不明白为什么除了我目前正在使用的文件(myrestjira.py)之外,还有对另一个文件(restjira.py)的引用我正在使用 python 2.7,jira-python 库,请求 0.14.1,jira- python 0.12 和 pycharm 作为 IDE 有人吗?