2013-09-27 25 views
1

我用“Bugzilla XMLRPC access module”在Python开发的Bugzilla的XML-RPC工作附上文件。如何通过“Bugzilla的XML-RPC访问模块”

如何我可以通过使用该模块加载/下载的Bugzilla文件?

根据guideline of API get_attachments_by_bug($ bug_id)检索并返回附件。

但是这个功能并没有为我工作,我得到了以下错误消息。

<type 'exceptions.AttributeError'>: 'Bugzilla4' object has no attribute 'get_attachments_by_bug' 

任何帮助,将不胜感激。

回答

1

FYI: 我在使用python-的Bugzilla工具的供应商联系,在这里我得到了他们的响应。

“不是所有的Bugzilla XMLRPC API由蟒蛇,Bugzilla的包裹,这是其中之一。

的‘Bugzilla的’命令行工具,蟒蛇,Bugzilla的船舶有命令的 安装文件和下载附件,采取看看代码有没有 指导意见“。


我想出办法如何通过使用“Bugzilla的XMLRPC接入模块”

你需要通过附加文件的ID作为参数传递给下面的函数来下载/上传附件

下载:

downloaded_file = bz.download_attachment(attachment_id) 
file_name = str(downloaded_file.name) 

上传:

kwards = { 
    'contenttype':'application/octet-stream', 
    # 'filename': file_path  #there could be more parameters if needed 
} 

#attachfile method will return the id of attached file 
bz.attachfile(bug_id, file_path, file_name, **kwards) 

但是附加的文件被损坏,由于一些XMP-RPC API的内部方法描述hereherehere,这是另一个问题:)