All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: bitbake-devel@lists.openembedded.org
Subject: [PATCH 1/4] cooker: add state.get_name method
Date: Thu, 31 Dec 2015 18:42:13 +0200	[thread overview]
Message-ID: <1451580136-29714-2-git-send-email-ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <1451580136-29714-1-git-send-email-ed.bartosh@linux.intel.com>

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>

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



  reply	other threads:[~2015-12-31 18:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-31 16:42 [PATCH 0/4] Improve error reporting for registerEventHandler Ed Bartosh
2015-12-31 16:42 ` Ed Bartosh [this message]
2015-12-31 16:42 ` [PATCH 2/4] uievent: add error to registerEventHandler return Ed Bartosh
2015-12-31 16:42 ` [PATCH 3/4] uievent: get rid of EventHandler attribute Ed Bartosh
2015-12-31 16:42 ` [PATCH 4/4] uievent: refactor retry loop Ed Bartosh
2016-01-02 19:29   ` Christopher Larson
2016-01-04  8:14     ` [PATCH v2] " Ed Bartosh
2016-01-04  9:26       ` [PATCH 4/4 v3] " Ed Bartosh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1451580136-29714-2-git-send-email-ed.bartosh@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.