Python错误“NoneType”对象没有属性“post”jira

2024-03-29 11:57:59 发布

您现在位置:Python中文网/ 问答频道 /正文

因此,我正在使用jira的模块与他们合作,试图执行问题转换,有时我会遇到这个错误。当队列中有两个以上的问题时会发生这种情况(当队列中有一个问题时,这种情况可以正常工作) 我的代码是:

def task2(self):
    while True:
        project.task1(self)
        time.sleep(20)

def task1(self):
    user = **
    pass = **
    jira_url = "jira.example.com"
    
    try:
       jira_options = ('server': JIRA_URL)
       jql_string = jira.search_issue("project = AB")
       logging.basicConfig(filename='log-file.log', filemode = '+a', level=DEBUG)
       for is_num in jql_string:
           issue_num = jira.issue(is_num)
           summ = issue.summary
           descr = issue.description
        //some other code that has nothing to do with jira//
           jira.add_comment(issue_num, "Добавить комментарий")
           jira.transition_issue(issue_num, "1", fields={'customfield_1':'text1', 'customfield_2':'text2'})
           print('well done')
       jira.close()
    time.sleep(5)
    except TypeError as te:
           jira.add_comment(issue_num, "Добавить комментарий")
           jira.transition_issue(issue_num, "1", fields={'customfield_1':'text1', 'customfield_2':'text2'})
    except Exception as exc: #for connection time out
           pass

有什么问题吗?它发生在队列中的第二个问题上。如果没有转换,它可以完美地工作(其他一些代码)

而且它不会崩溃,即使在Exception中只有print('smth'),也不会使用错误或调试级别记录回溯

在调试日志中,只有201和204个状态响应

添加日志。我正在尝试用俄语添加评论,尽管出现了错误,但仍然会在请求中添加评论。IDK。。。猜一些编码错误。 错误:

File "C:\script\task-jira.py", line 231 in add_comm
jira.add_comment(issue, 'xc07 xE0 xFF xE2')

然后在包装器中的client.py中出现错误并添加注释。 添加注释

r = self._session.post(AttributeError: 'NoneType' object has no attribute 'post'

Tags: 代码selfprojectaddtime队列def错误