| Line 15... |
Line 15... |
| 15 |
self.runtime_defects = {}
|
15 |
self.runtime_defects = {}
|
| 16 |
self.maintenance_defects = {}
|
16 |
self.maintenance_defects = {}
|
| 17 |
self.security_defects = {}
|
17 |
self.security_defects = {}
|
| 18 |
self.unclassified_defect_reviews = [ ]
|
18 |
self.unclassified_defect_reviews = [ ]
|
| 19 |
self.total_defects = 0
|
19 |
self.total_defects = 0
|
| - |
|
20 |
self.verbose = False
|
| 20 |
def url_to_object(self, url, top=None) :
|
21 |
def url_to_object(self, url, top=None) :
|
| 21 |
req = urllib2.Request(url)
|
22 |
req = urllib2.Request(url)
|
| 22 |
req.add_header('Accept','application/json')
|
23 |
req.add_header('Accept','application/json')
|
| 23 |
req.add_header('Authorization', 'Basic dGxpdHRsZWY6MCRtb3JQRVRI')
|
24 |
req.add_header('Authorization', 'Basic dGxpdHRsZWY6MCRtb3JQRVRI')
|
| 24 |
resp = urllib2.urlopen(req).read()
|
25 |
resp = urllib2.urlopen(req).read()
|
| Line 64... |
Line 65... |
| 64 |
retval[3] += 1
|
65 |
retval[3] += 1
|
| 65 |
category_defect_map = self.maintenance_defects
|
66 |
category_defect_map = self.maintenance_defects
|
| 66 |
elif defect_category_code == u'metric-95' : # runtime
|
67 |
elif defect_category_code == u'metric-95' : # runtime
|
| 67 |
retval[2] += 1
|
68 |
retval[2] += 1
|
| 68 |
category_defect_map = self.runtime_defects
|
69 |
category_defect_map = self.runtime_defects
|
| 69 |
else :
|
- |
|
| 70 |
print c[u'metrics'].keys()[0] # security - haven't seen one yet so want to know what the metric- code is
|
70 |
elif defect_category_code == u'metric-97' : # security
|
| 71 |
retval[4] += 1
|
71 |
retval[4] += 1
|
| 72 |
category_defect_map = self.security_defects
|
72 |
category_defect_map = self.security_defects
|
| - |
|
73 |
else :
|
| - |
|
74 |
print u"Unexpected defect_category_code %s" % ( c[u'metrics'].keys()[0] )
|
| - |
|
75 |
retval[5] += 1
|
| - |
|
76 |
self.unclassified_defect_reviews += [ review_id ]
|
| - |
|
77 |
self.total_defects += 1
|
| 73 |
if defect_type in category_defect_map.keys() :
|
78 |
if defect_type in category_defect_map.keys() :
|
| 74 |
category_defect_map[defect_type] += 1
|
79 |
category_defect_map[defect_type] += 1
|
| 75 |
else :
|
80 |
else :
|
| 76 |
category_defect_map[defect_type] = 1
|
81 |
category_defect_map[defect_type] = 1
|
| 77 |
|
82 |
|
| Line 79... |
Line 84... |
| 79 |
self.selected_reviews[review_id][1] = retval[2:]
|
84 |
self.selected_reviews[review_id][1] = retval[2:]
|
| 80 |
return retval
|
85 |
return retval
|
| 81 |
def summarize_by_project(self, month_prefix) :
|
86 |
def summarize_by_project(self, month_prefix) :
|
| 82 |
start_date = month_prefix + "-00"
|
87 |
start_date = month_prefix + "-00"
|
| 83 |
end_date = month_prefix + "-99"
|
88 |
end_date = month_prefix + "-99"
|
| - |
|
89 |
if self.verbose :
|
| 84 |
print "Getting review ids"
|
90 |
print "Getting review ids"
|
| 85 |
review_ids = self.get_selected_review_ids(start_date, end_date)
|
91 |
review_ids = self.get_selected_review_ids(start_date, end_date)
|
| 86 |
project_summaries = {}
|
92 |
project_summaries = {}
|
| 87 |
overall_summary = [ 0, ] * 6
|
93 |
overall_summary = [ 0, ] * 6
|
| 88 |
for review_id in sorted(review_ids) :
|
94 |
for review_id in sorted(review_ids) :
|
| 89 |
if True :
|
95 |
if True :
|
| 90 |
review_summary = self.get_review_summary(review_id)
|
96 |
review_summary = self.get_review_summary(review_id)
|
| - |
|
97 |
if self.verbose :
|
| 91 |
print "%-12s: %s" % ( review_id, self.selected_reviews[review_id][1] )
|
98 |
print "%-12s: %s" % ( review_id, self.selected_reviews[review_id][1] )
|
| 92 |
project_id = review_summary[0]
|
99 |
project_id = review_summary[0]
|
| 93 |
if project_id in project_summaries.keys() :
|
100 |
if project_id in project_summaries.keys() :
|
| 94 |
project_summary = project_summaries[project_id]
|
101 |
project_summary = project_summaries[project_id]
|
| 95 |
else :
|
102 |
else :
|
| 96 |
project_summary = [ 0,] * 6
|
103 |
project_summary = [ 0,] * 6
|
| Line 136... |
Line 143... |
| 136 |
def report_on_unclassified_defects(self) :
|
143 |
def report_on_unclassified_defects(self) :
|
| 137 |
print "Reviews with unclassified defects: %s" % (self.unclassified_defect_reviews,)
|
144 |
print "Reviews with unclassified defects: %s" % (self.unclassified_defect_reviews,)
|
| 138 |
|
145 |
|
| 139 |
if __name__ == "__main__" :
|
146 |
if __name__ == "__main__" :
|
| 140 |
extractor = CrucibleExtractor()
|
147 |
extractor = CrucibleExtractor()
|
| - |
|
148 |
|
| - |
|
149 |
if sys.argv[1] == "--usage" :
|
| - |
|
150 |
print "crucible_reporting.py YYYY-MM"
|
| - |
|
151 |
print " report stats for specified month"
|
| - |
|
152 |
print "crucible_reporting.py"
|
| - |
|
153 |
print " report stats for previous month"
|
| - |
|
154 |
sys.exit(0)
|
| - |
|
155 |
elif sys.argv[1] == "--verbose" :
|
| - |
|
156 |
extractor.verbose = True
|
| - |
|
157 |
sys.argv = sys.argv[1:]
|
| - |
|
158 |
|
| 141 |
if len(sys.argv) < 2 :
|
159 |
if len(sys.argv) < 2 :
|
| 142 |
today = datetime.date.today()
|
160 |
today = datetime.date.today()
|
| 143 |
if today.month!= 1 :
|
161 |
if today.month!= 1 :
|
| 144 |
month_prefix = "%04d-%02d" % (today.year, today.month-1)
|
162 |
month_prefix = "%04d-%02d" % (today.year, today.month-1)
|
| 145 |
else :
|
163 |
else :
|
| 146 |
month_prefix = "%04d-%02d" % (today.year-1, 12)
|
164 |
month_prefix = "%04d-%02d" % (today.year-1, 12)
|
| 147 |
print "Generating report for previous month (" + month_prefix + ")"
|
165 |
print "Generating report for previous month (" + month_prefix + ")"
|
| 148 |
elif sys.argv[1] == "--usage" :
|
- |
|
| 149 |
print "crucible_reporting.py YYYY-MM"
|
- |
|
| 150 |
print " report stats for specified month"
|
- |
|
| 151 |
print "crucible_reporting.py"
|
- |
|
| 152 |
print " report stats for previous month"
|
- |
|
| 153 |
sys.exit(0)
|
- |
|
| 154 |
else :
|
166 |
else :
|
| 155 |
month_prefix = sys.argv[1]
|
167 |
month_prefix = sys.argv[1]
|
| 156 |
|
168 |
|
| 157 |
extractor.summarize_by_project(month_prefix)
|
169 |
extractor.summarize_by_project(month_prefix)
|
| 158 |
extractor.summarize_by_defect_type()
|
170 |
extractor.summarize_by_defect_type()
|