2013-09-27 34 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,這是另一個問題:)