summaryrefslogtreecommitdiff
path: root/meta/lib
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:31:21 +0000
commit255d4bbf4d1e430d45f5fafb7d1c77d9ea67e174 (patch)
treecb7260c4ccc0281f8831e6c0d7812a7ffa5f5262 /meta/lib
parent15ad5d2c0e92fefdbb7c0cf064134b1cabfd84ac (diff)
downloadopenembedded-core-255d4bbf4d1e430d45f5fafb7d1c77d9ea67e174.tar.gz
openembedded-core-255d4bbf4d1e430d45f5fafb7d1c77d9ea67e174.tar.bz2
openembedded-core-255d4bbf4d1e430d45f5fafb7d1c77d9ea67e174.tar.xz
openembedded-core-255d4bbf4d1e430d45f5fafb7d1c77d9ea67e174.zip
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) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-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 a2fa64307..627467c26 100644
--- a/meta/lib/oe/buildhistory_analysis.py
+++ b/meta/lib/oe/buildhistory_analysis.py
@@ -40,10 +40,13 @@ class ChangeRecord:
added = list(set(bitems) - set(aitems))
return '%s: %s:%s%s' % (self.path, self.fieldname, ' removed "%s"' % ' '.join(removed) if removed else '', ' added "%s"' % ' '.join(added) if added else '')
elif self.fieldname in numeric_fields:
- aval = int(self.oldvalue)
- bval = int(self.newvalue)
- percentchg = ((bval - aval) / float(aval)) * 100
- return '%s: %s changed from %d to %d (%s%d%%)' % (self.path, self.fieldname, aval, bval, '+' if percentchg > 0 else '', percentchg)
+ aval = int(self.oldvalue or 0)
+ bval = int(self.newvalue or 0)
+ if aval != 0:
+ percentchg = ((bval - aval) / float(aval)) * 100
+ else:
+ percentchg = 100
+ 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)
elif self.fieldname in img_monitor_files:
out = 'Changes to %s (%s):\n ' % (self.path, self.fieldname)
if self.filechanges:
@@ -194,16 +197,22 @@ def compare_dict_blobs(path, ablob, bblob, report_all):
bdict = blob_to_dict(bblob)
changes = []
- for key in adict:
+ keys = list(set(adict.keys()) | set(bdict.keys()))
+ for key in keys:
if report_all or key in monitor_fields:
- if adict[key] != bdict[key]:
+ astr = adict.get(key, '')
+ bstr = bdict.get(key, '')
+ if astr != bstr:
if (not report_all) and key in numeric_fields:
- aval = int(adict[key])
- bval = int(bdict[key])
- percentchg = ((bval - aval) / float(aval)) * 100
+ aval = int(astr or 0)
+ bval = int(bstr or 0)
+ if aval != 0:
+ percentchg = ((bval - aval) / float(aval)) * 100
+ else:
+ percentchg = 100
if percentchg < monitor_numeric_threshold:
continue
- chg = ChangeRecord(path, key, adict[key], bdict[key])
+ chg = ChangeRecord(path, key, astr, bstr)
changes.append(chg)
return changes