-
Notifications
You must be signed in to change notification settings - Fork 0
/
bugzilla_helper.py
91 lines (81 loc) · 2.46 KB
/
bugzilla_helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
import xmlrpclib
from login import getServer
class BugzillaHelper(object):
def __init__(self):
self.server = getServer()
# Get bug data-structure corresponding to a PR number
def getInfo(self, pr):
try:
bugInfo = self.server.Bug.show_bug(int(pr))
return bugInfo
except ValueError as value_err:
raise Exception(value_err)
except xmlrpclib.Fault as not_found_err:
raise Exception(not_found_err)
except:
raise
# Add comment to a PR
def addComment(self, pr, comment):
try:
self.server.Bug.add_comment(pr, comment)
except xmlrpclib.Fault as not_found_err:
raise Exception(not_found_err)
except:
raise
# Get summary, which is the title, for a PR
def getSummary(self, pr):
try:
bugInfo = self.getInfo(pr)
return bugInfo['short_desc']
except:
raise
# Get assignee for a PR
# XXX: Side effects: Crashes if incorrect reporter name is passed
def getAssignee(self, pr):
try:
bugInfo = self.getInfo(pr)
return bugInfo['assigned_to']
except:
raise
# Get reporter for a PR
# XXX: Side effects: Crashes if incorrect reporter name is passed
def getReporter(self, pr):
try:
bugInfo = self.getInfo(pr)
return bugInfo['reporter']
except:
raise
# Get list of saved searches for a user-name
def getSavedQueries(self, uName):
try:
savedSearch = self.server.Search.get_all_saved_queries(uName)
return savedSearch
except ValueError as value_err:
raise Exception(value_err)
except xmlrpclib.Fault as not_found_err:
raise Exception(not_found_err)
except:
raise
# Get bug list in a saved query
#XXX API does not use uName paramter
def getBugList(self, uName, query):
try:
bugList = self.server.Search.run_saved_query(uName, query)['bugidlist']
return str(bugList)
except ValueError as value_err:
raise Exception(value_err)
except xmlrpclib.Fault as not_found_err:
raise Exception(not_found_err)
except:
raise
def getUpdate0(self, pr):
try:
bugInfo = self.getInfo(pr)
return bugInfo['description']
except:
raise
if __name__ == '__main__':
test = BugzillaHelper()
#print test.getSavedQueries('kotwala')
test.addComment('1778172', 'testComment')