From 01419d5565a5e3762ec4a2a382f2099683615e52 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Thu, 31 Dec 2015 18:42:13 +0200 Subject: bitbake: cooker: add state.get_name method Added method to convert state code into the human readable name. It will be used in logging and error reporting. (Bitbake rev: 9ec6379b27d210214d0b3f2e55962f721b7f5f51) Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bitbake/lib/bb/cooker.py') diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 5ceb198c05..edceca00ed 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): -- cgit v1.2.3-54-g00ecf