Bugzilla 导出CSV 脚本化
? bugzilla ? ? python ?    2019-01-11 16:22:44    1186    0    0

需求

1. 根据bug list 导出表格

2. 指定显示固定字段

3. 使用bugzilla 自有的导出CSV 格式


思路

1. bugzilla 导出查询结果的功能已有,可以直接在页面点击csv , 通过浏览器直接下载表格。

2. 需求转化为如何生成下载csv 的url 。

3. 取一个url 进行分析 ,抽取其中的 bug list 和固定字段 进行切割,使下载链接模板化。

4. 使用bug list 和固定字段作为参数,对url 模板进行实例化。

5. 其他: 模拟浏览器 ,进行登录,下载 。

6. 扩展: 修改值,提交修改。


获取导出url

1. 在搜索框输入 bug list : 777  888 ,点search

或是在search --> 高级搜索中设置搜索条件

2. 在第1步 的搜索结果页面中,点击列表下方的“change columns” ,选择需要显示的字段,点击保存

3. 页面从change columns 跳转回结果页面,点击下面的 CSV

4. 浏览器跳出保存 CSV 文档的对话框,点击取消,将此时地址栏的url 

https://xxx.xxx.xxx.xxx:38887/buglist.cgi?bug_id=777%2C888&columnlist=product%2Ccomponent%2Cbug_status%2Cresolution%2Ccf_major_version_fixed%2Ccf_fixed_build_in_lte%2Cshort_desc%2Cassigned_to%2Creporter&query_format=advanced&ctype=csv


Url 解析:

1. https://xxx.xxx.xxx.xxx:38887/   即为bugzilla 的首页访问地址

2. buglist.cgi?bug_id=777%2C888  即为bug list 的信息

1,2 可以抽取为模板:  https://xxx.xxx.xxx.xxx:38887/buglist.cgi?bug_id=   +  bugID + %2C bugID

另一个高级搜索的样式(非以id 为条件,以具体的字段值为条件)

http://192.168.x.x:38888/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&product=LTE-HeNBGW&query_format=advanced

 

3. 字段格式:

&columnlist=product%2Ccomponent%2Cbug_status%2Cresolution%2Ccf_major_version_fixed%2Ccf_fixed_build_in_lte%2Cshort_desc%2Cassigned_to%2Creporter&query_format=advanced&ctype=csv

当我们需要的字段固定时,可以直接使用此段,当此部分也需要抽取时,可使用以下模板:

&columnlist=字段名%2字段名%2字段名%2字段名....&ctype=csv

 


以下为一个用python 写的检出的函数:

 
def Export_csv(version):
 url = 'https://xxx.xxx.xxx.xxx:38887/buglist.cgi?bug_id='
 count = 0
 t = open("bug_list.txt")
 for list in t.readlines():
 list = list.rstrip('\n')
 print list
 if count > 0:
 url = url + "%2C"
 url = url + list
 count = count + 1
 url = url + "&bug_id_type=anyexact&query_format=advanced&query_based_on=&columnlist=product%2Ccomponent%2Cbug_status%2Cresolution%2Ccf_major_version_fixed%2Ccf_fixed_build_in_lte%2Cshort_desc%2Cassigned_to%2Creporter&ctype=csv"
 print url
 file_name = version + "_release_note.csv"
 f = br.retrieve(url,file_name)[0]
 print "the csv file "+ f +" has been downloaded ."​

 

 


 

 

Pre: GitLab GEO 异地主副服务器同步--文档翻译

Next: mount/nfs 共享目录

1186
Sign in to leave a comment.
No Leanote account? Sign up now.
0 comments
Table of content