summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2012-01-19 10:32:11 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-19 14:34:33 +0000
commit5cf28333a7fce346f743fd053dd992dda6bb8fba (patch)
tree87f3a2467b3174ccad5e5f31a0e1fa91b730474b /meta/lib/oe
parentc1cebf6a2ba4661e8e46842413eef9a69a49fd47 (diff)
downloadpoky-5cf28333a7fce346f743fd053dd992dda6bb8fba.tar.gz
buildhistory_analysis: improve field handling robustness
Avoid errors when comparing changes for KEY = value files (package info files and image-info.txt): * Handle keys appearing and disappearing - this will help to handle PE in package info files (which is only written when it is not blank) and when we add additional fields in future. * Handle when old value is 0 for numeric field (avoid division by zero) * Report when numeric field was empty or missing rather than 0 (but still treat it as 0 for comparison purposes) (From OE-Core rev: 255d4bbf4d1e430d45f5fafb7d1c77d9ea67e174) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/buildhistory_analysis.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/meta/lib/oe/buildhistory_analysis.py b/meta/lib/oe/buildhistory_analysis.py
index a2fa643077..627467c26e 100644
--- a/meta/lib/oe/buildhistory_analysis.py
+++ b/meta/lib/oe/buildhistory_analysis.py
@@ -40,10 +40,13 @@ class ChangeRecord:
40 added = list(set(bitems) - set(aitems)) 40 added = list(set(bitems) - set(aitems))
41 return '%s: %s:%s%s' % (self.path, self.fieldname, ' removed "%s"' % ' '.join(removed) if removed else '', ' added "%s"' % ' '.join(added) if added else '') 41 return '%s: %s:%s%s' % (self.path, self.fieldname, ' removed "%s"' % ' '.join(removed) if removed else '', ' added "%s"' % ' '.join(added) if added else '')
42 elif self.fieldname in numeric_fields: 42 elif self.fieldname in numeric_fields:
43 aval = int(self.oldvalue) 43 aval = int(self.oldvalue or 0)
44 bval = int(self.newvalue) 44 bval = int(self.newvalue or 0)
45 percentchg = ((bval - aval) / float(aval)) * 100 45 if aval != 0:
46 return '%s: %s changed from %d to %d (%s%d%%)' % (self.path, self.fieldname, aval, bval, '+' if percentchg > 0 else '', percentchg) 46 percentchg = ((bval - aval) / float(aval)) * 100
47 else:
48 percentchg = 100
49 return '%s: %s changed from %s to %s (%s%d%%)' % (self.path, self.fieldname, self.oldvalue or "''", self.newvalue or "''", '+' if percentchg > 0 else '', percentchg)
47 elif self.fieldname in img_monitor_files: 50 elif self.fieldname in img_monitor_files:
48 out = 'Changes to %s (%s):\n ' % (self.path, self.fieldname) 51 out = 'Changes to %s (%s):\n ' % (self.path, self.fieldname)
49 if self.filechanges: 52 if self.filechanges:
@@ -194,16 +197,22 @@ def compare_dict_blobs(path, ablob, bblob, report_all):
194 bdict = blob_to_dict(bblob) 197 bdict = blob_to_dict(bblob)
195 198
196 changes = [] 199 changes = []
197 for key in adict: 200 keys = list(set(adict.keys()) | set(bdict.keys()))
201 for key in keys:
198 if report_all or key in monitor_fields: 202 if report_all or key in monitor_fields:
199 if adict[key] != bdict[key]: 203 astr = adict.get(key, '')
204 bstr = bdict.get(key, '')
205 if astr != bstr:
200 if (not report_all) and key in numeric_fields: 206 if (not report_all) and key in numeric_fields:
201 aval = int(adict[key]) 207 aval = int(astr or 0)
202 bval = int(bdict[key]) 208 bval = int(bstr or 0)
203 percentchg = ((bval - aval) / float(aval)) * 100 209 if aval != 0:
210 percentchg = ((bval - aval) / float(aval)) * 100
211 else:
212 percentchg = 100
204 if percentchg < monitor_numeric_threshold: 213 if percentchg < monitor_numeric_threshold:
205 continue 214 continue
206 chg = ChangeRecord(path, key, adict[key], bdict[key]) 215 chg = ChangeRecord(path, key, astr, bstr)
207 changes.append(chg) 216 changes.append(chg)
208 return changes 217 return changes
209 218