[bitbake-devel] [PATCH 1/4] cooker: add state.get_name method

Ed Bartosh ed.bartosh at linux.intel.com
Thu Dec 31 16:42:13 UTC 2015


Added method to convert state code into the human readable name.
It will be used in logging and error reporting.

Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>

diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 4df8881..1d83226 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -67,6 +67,14 @@ class CollectionError(bb.BBHandledException):
 class state:
     initial, parsing, running, shutdown, forceshutdown, stopped, error = range(7)
 
+    @classmethod
+    def get_name(cls, code):
+        for name in dir(cls):
+            value = getattr(cls, name)
+            if type(value) == type(cls.initial) and value == code:
+                return name
+        raise ValueError("Invalid status code: %s" % code)
+
 
 class SkippedPackage:
     def __init__(self, info = None, reason = None):
-- 
2.1.4




More information about the bitbake-devel mailing list