]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
cooker: add state.get_name method
authorEd Bartosh <ed.bartosh@linux.intel.com>
Thu, 31 Dec 2015 16:42:13 +0000 (18:42 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 5 Jan 2016 17:59:13 +0000 (17:59 +0000)
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@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/cooker.py

index 5ceb198c056d84e88725721ad49cdb44ba520bc3..edceca00ed1aa00b585aad5f39257ee299c1a4fe 100644 (file)
@@ -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):