通过 jira python 添加附件到 jira 问题(添加了空文件)
Add attachment to a jira issue via jira python (empty file added)
我正在尝试使用 jira python API 向现有的 jira 问题添加附件。
我能够创建问题、更新它们以及与问题相关的任何操作,但是当我尝试添加附件时,我要么收到 200 响应,要么收到一条错误消息,指出添加的附件是空的(它实际上是空的)或显示 "No space left on device" 的错误,我不认为这是关于 space 的,因为我可以在 jira 界面上手动添加附件。
我的代码将第一条信息添加到新文件中,然后尝试将其附加到问题中。请注意,我的代码目录中的实际文件不是空的,符合我的预期。
f = open("matriceFlux.csv","w+")
ligneEntete = ";".join(entete)+"\n"
f.write(ligneEntete)
for valeur in valeurs:
ligne=";".join(valeur)+"\n"
f.write(ligne)
f.close() #I didn't close the files object for the first try
fichier=open("matriceFlux.csv", 'rb')
jira.add_attachment(issue=fluxIssue, attachment=fichier)
matriceFlux.close() #I didn't close the files object for the first try
输出为
raise JIRAError("Added empty attachment via %s method?!: r:
%s\nattachment: %s" % (method, r, attachment))
jira.exceptions.JIRAError: JiraError HTTP Added empty attachment via
MultipartEncoder method?!: r: <Response [200]>
attachment: matriceFlux.csv
当我不关闭文件对象时
当我做这个时
jira.exceptions.JIRAError: JiraError HTTP 500 url: https://rec-
jira.*******.fr/rest/api/2/issue/GDIOP-15782/attachments
text: No space left on device
response headers = {'X-AREQUESTID': '562x1107300x1', 'X-ASESSIONID':
'g9s4x6', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options':
'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy':
"frame-ancestors 'self'", 'X-ASEN': 'SEN-2015665', 'X-Seraph-
LoginReason': 'OK', 'X-AUSERNAME': 'my752lf', 'Cache-Control': 'no-cache,
no-store, no-transform', 'Content-Type': 'application/json;charset=UTF-
8', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 11 Jul 2019 07:22:23
GMT', 'Connection': 'close'}
response text = No space left on device
问题实际上与 jira 服务器上的 space 有关....在 dba 清理它之后,文件附加到问题上。此外,由于我第一次没有关闭文件对象,我的代码创建了另一个文件,该文件是添加的空文件。
希望对大家有所帮助。
我正在尝试使用 jira python API 向现有的 jira 问题添加附件。
我能够创建问题、更新它们以及与问题相关的任何操作,但是当我尝试添加附件时,我要么收到 200 响应,要么收到一条错误消息,指出添加的附件是空的(它实际上是空的)或显示 "No space left on device" 的错误,我不认为这是关于 space 的,因为我可以在 jira 界面上手动添加附件。
我的代码将第一条信息添加到新文件中,然后尝试将其附加到问题中。请注意,我的代码目录中的实际文件不是空的,符合我的预期。
f = open("matriceFlux.csv","w+")
ligneEntete = ";".join(entete)+"\n"
f.write(ligneEntete)
for valeur in valeurs:
ligne=";".join(valeur)+"\n"
f.write(ligne)
f.close() #I didn't close the files object for the first try
fichier=open("matriceFlux.csv", 'rb')
jira.add_attachment(issue=fluxIssue, attachment=fichier)
matriceFlux.close() #I didn't close the files object for the first try
输出为
raise JIRAError("Added empty attachment via %s method?!: r:
%s\nattachment: %s" % (method, r, attachment))
jira.exceptions.JIRAError: JiraError HTTP Added empty attachment via
MultipartEncoder method?!: r: <Response [200]>
attachment: matriceFlux.csv
当我不关闭文件对象时
当我做这个时
jira.exceptions.JIRAError: JiraError HTTP 500 url: https://rec-
jira.*******.fr/rest/api/2/issue/GDIOP-15782/attachments
text: No space left on device
response headers = {'X-AREQUESTID': '562x1107300x1', 'X-ASESSIONID':
'g9s4x6', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options':
'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy':
"frame-ancestors 'self'", 'X-ASEN': 'SEN-2015665', 'X-Seraph-
LoginReason': 'OK', 'X-AUSERNAME': 'my752lf', 'Cache-Control': 'no-cache,
no-store, no-transform', 'Content-Type': 'application/json;charset=UTF-
8', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 11 Jul 2019 07:22:23
GMT', 'Connection': 'close'}
response text = No space left on device
问题实际上与 jira 服务器上的 space 有关....在 dba 清理它之后,文件附加到问题上。此外,由于我第一次没有关闭文件对象,我的代码创建了另一个文件,该文件是添加的空文件。
希望对大家有所帮助。