All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Show close matches for invalid task/target
@ 2013-08-13 14:18 Paul Eggleton
  2013-08-13 14:18 ` [PATCH 1/2] runqueue: report close matches for an invalid task name Paul Eggleton
  2013-08-13 14:18 ` [PATCH 2/2] taskdata: report close matches with NoProvider errors Paul Eggleton
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Eggleton @ 2013-08-13 14:18 UTC (permalink / raw)
  To: bitbake-devel

The following changes (against poky, but apply cleanly with -p2 against
bitbake master) are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib paule/closematch
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/closematch

Paul Eggleton (2):
  runqueue: report close matches for an invalid task name
  taskdata: report close matches with NoProvider errors

 bitbake/lib/bb/event.py                  |  3 ++-
 bitbake/lib/bb/runqueue.py               |  6 +++++-
 bitbake/lib/bb/taskdata.py               | 13 ++++++++++++-
 bitbake/lib/bb/ui/crumbs/runningbuild.py | 10 ++++++++--
 bitbake/lib/bb/ui/knotty.py              |  9 +++++++--
 5 files changed, 34 insertions(+), 7 deletions(-)

-- 
1.8.1.2



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] runqueue: report close matches for an invalid task name
  2013-08-13 14:18 [PATCH 0/2] Show close matches for invalid task/target Paul Eggleton
@ 2013-08-13 14:18 ` Paul Eggleton
  2013-08-13 20:18   ` Richard Purdie
  2013-08-13 14:18 ` [PATCH 2/2] taskdata: report close matches with NoProvider errors Paul Eggleton
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Eggleton @ 2013-08-13 14:18 UTC (permalink / raw)
  To: bitbake-devel

Help to pick up mistakes such as "bitbake -c cleanstate xyz" (instead
of "bitbake -c cleansstate xyz".)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 bitbake/lib/bb/runqueue.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index b2c9703..b3374f1 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -601,7 +601,11 @@ class RunQueueData:
                 continue
 
             if target[1] not in taskData.tasks_lookup[fnid]:
-                bb.msg.fatal("RunQueue", "Task %s does not exist for target %s" % (target[1], target[0]))
+                import difflib
+                close_matches = difflib.get_close_matches(target[1], taskData.tasks_lookup[fnid], cutoff=0.7)
+                if close_matches:
+                    extra = ". Close matches:\n  %s" % "\n  ".join(close_matches)
+                bb.msg.fatal("RunQueue", "Task %s does not exist for target %s%s" % (target[1], target[0], extra))
 
             listid = taskData.tasks_lookup[fnid][target[1]]
 
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] taskdata: report close matches with NoProvider errors
  2013-08-13 14:18 [PATCH 0/2] Show close matches for invalid task/target Paul Eggleton
  2013-08-13 14:18 ` [PATCH 1/2] runqueue: report close matches for an invalid task name Paul Eggleton
@ 2013-08-13 14:18 ` Paul Eggleton
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Eggleton @ 2013-08-13 14:18 UTC (permalink / raw)
  To: bitbake-devel

Assuming there is no known reason why an item is not provided, show
close matches on the assumption that it might have been a typo or
other mistake.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 bitbake/lib/bb/event.py                  |  3 ++-
 bitbake/lib/bb/taskdata.py               | 13 ++++++++++++-
 bitbake/lib/bb/ui/crumbs/runningbuild.py | 10 ++++++++--
 bitbake/lib/bb/ui/knotty.py              |  9 +++++++--
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 9c134ee..ba25d38 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -341,12 +341,13 @@ class DiskFull(Event):
 class NoProvider(Event):
     """No Provider for an Event"""
 
-    def __init__(self, item, runtime=False, dependees=None, reasons=[]):
+    def __init__(self, item, runtime=False, dependees=None, reasons=[], close_matches=[]):
         Event.__init__(self)
         self._item = item
         self._runtime = runtime
         self._dependees = dependees
         self._reasons = reasons
+        self._close_matches = close_matches
 
     def getItem(self):
         return self._item
diff --git a/bitbake/lib/bb/taskdata.py b/bitbake/lib/bb/taskdata.py
index c08186a..58fe199 100644
--- a/bitbake/lib/bb/taskdata.py
+++ b/bitbake/lib/bb/taskdata.py
@@ -390,6 +390,17 @@ class TaskData:
                     reasons.append("%s PROVIDES %s but was skipped: %s" % (skipitem.pn, item, skipitem.skipreason))
         return reasons
 
+    def get_close_matches(self, item, provider_list):
+        import difflib
+        if self.skiplist:
+            skipped = []
+            for fn in self.skiplist:
+                skipped.append(self.skiplist[fn].pn)
+            full_list = provider_list + skipped
+        else:
+            full_list = provider_list
+        return difflib.get_close_matches(item, full_list, cutoff=0.7)
+
     def add_provider(self, cfgData, dataCache, item):
         try:
             self.add_provider_internal(cfgData, dataCache, item)
@@ -411,7 +422,7 @@ class TaskData:
             return
 
         if not item in dataCache.providers:
-            bb.event.fire(bb.event.NoProvider(item, dependees=self.get_dependees_str(item), reasons=self.get_reasons(item)), cfgData)
+            bb.event.fire(bb.event.NoProvider(item, dependees=self.get_dependees_str(item), reasons=self.get_reasons(item), close_matches=self.get_close_matches(item, dataCache.providers.keys())), cfgData)
             raise bb.providers.NoProvider(item)
 
         if self.have_build_target(item):
diff --git a/bitbake/lib/bb/ui/crumbs/runningbuild.py b/bitbake/lib/bb/ui/crumbs/runningbuild.py
index 78fa141..abd3300 100644
--- a/bitbake/lib/bb/ui/crumbs/runningbuild.py
+++ b/bitbake/lib/bb/ui/crumbs/runningbuild.py
@@ -375,10 +375,16 @@ class RunningBuild (gobject.GObject):
                 r = "R"
             else:
                 r = ""
+
+            extra = ''
+            if not event._reasons:
+                if event._close_matches:
+                    extra = ". Close matches:\n  %s" % '\n  '.join(event._close_matches)
+
             if event._dependees:
-                msg = "Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)\n" % (r, event._item, ", ".join(event._dependees), r)
+                msg = "Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s\n" % (r, event._item, ", ".join(event._dependees), r, extra)
             else:
-                msg = "Nothing %sPROVIDES '%s'\n" % (r, event._item)
+                msg = "Nothing %sPROVIDES '%s'%s\n" % (r, event._item, extra)
             if event._reasons:
                 for reason in event._reasons:
                     msg += ("%s\n" % reason)
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 2c8293d..09ad99e 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -416,10 +416,15 @@ def main(server, eventHandler, params, tf = TerminalFilter):
                 else:
                     r = ""
 
+                extra = ''
+                if not event._reasons:
+                    if event._close_matches:
+                        extra = ". Close matches:\n  %s" % '\n  '.join(event._close_matches)
+
                 if event._dependees:
-                    logger.error("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)", r, event._item, ", ".join(event._dependees), r)
+                    logger.error("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s", r, event._item, ", ".join(event._dependees), r, extra)
                 else:
-                    logger.error("Nothing %sPROVIDES '%s'", r, event._item)
+                    logger.error("Nothing %sPROVIDES '%s'%s", r, event._item, extra)
                 if event._reasons:
                     for reason in event._reasons:
                         logger.error("%s", reason)
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] runqueue: report close matches for an invalid task name
  2013-08-13 14:18 ` [PATCH 1/2] runqueue: report close matches for an invalid task name Paul Eggleton
@ 2013-08-13 20:18   ` Richard Purdie
  2013-08-13 20:46     ` Paul Eggleton
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Purdie @ 2013-08-13 20:18 UTC (permalink / raw)
  To: Paul Eggleton; +Cc: bitbake-devel

On Tue, 2013-08-13 at 15:18 +0100, Paul Eggleton wrote:
> Help to pick up mistakes such as "bitbake -c cleanstate xyz" (instead
> of "bitbake -c cleansstate xyz".)
> 
> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
> ---
>  bitbake/lib/bb/runqueue.py | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
> index b2c9703..b3374f1 100644
> --- a/bitbake/lib/bb/runqueue.py
> +++ b/bitbake/lib/bb/runqueue.py
> @@ -601,7 +601,11 @@ class RunQueueData:
>                  continue
>  
>              if target[1] not in taskData.tasks_lookup[fnid]:
> -                bb.msg.fatal("RunQueue", "Task %s does not exist for target %s" % (target[1], target[0]))
> +                import difflib
> +                close_matches = difflib.get_close_matches(target[1], taskData.tasks_lookup[fnid], cutoff=0.7)
> +                if close_matches:
> +                    extra = ". Close matches:\n  %s" % "\n  ".join(close_matches)
> +                bb.msg.fatal("RunQueue", "Task %s does not exist for target %s%s" % (target[1], target[0], extra))

Missing else: extra = ""?

Cheers,

Richard



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] runqueue: report close matches for an invalid task name
  2013-08-13 20:18   ` Richard Purdie
@ 2013-08-13 20:46     ` Paul Eggleton
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Eggleton @ 2013-08-13 20:46 UTC (permalink / raw)
  To: Richard Purdie; +Cc: bitbake-devel

On Tuesday 13 August 2013 21:18:18 Richard Purdie wrote:
> On Tue, 2013-08-13 at 15:18 +0100, Paul Eggleton wrote:
> > Help to pick up mistakes such as "bitbake -c cleanstate xyz" (instead
> > of "bitbake -c cleansstate xyz".)
> > 
> > Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
> > ---
> > 
> >  bitbake/lib/bb/runqueue.py | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
> > index b2c9703..b3374f1 100644
> > --- a/bitbake/lib/bb/runqueue.py
> > +++ b/bitbake/lib/bb/runqueue.py
> > 
> > @@ -601,7 +601,11 @@ class RunQueueData:
> >                  continue
> >              
> >              if target[1] not in taskData.tasks_lookup[fnid]:
> > -                bb.msg.fatal("RunQueue", "Task %s does not exist for
> > target %s" % (target[1], target[0])) +                import difflib
> > +                close_matches = difflib.get_close_matches(target[1],
> > taskData.tasks_lookup[fnid], cutoff=0.7) +                if
> > close_matches:
> > +                    extra = ". Close matches:\n  %s" % "\n 
> > ".join(close_matches) +                bb.msg.fatal("RunQueue", "Task %s
> > does not exist for target %s%s" % (target[1], target[0], extra))
> Missing else: extra = ""?

Oops. Fixed on the branch.

Thanks,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-13 20:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-13 14:18 [PATCH 0/2] Show close matches for invalid task/target Paul Eggleton
2013-08-13 14:18 ` [PATCH 1/2] runqueue: report close matches for an invalid task name Paul Eggleton
2013-08-13 20:18   ` Richard Purdie
2013-08-13 20:46     ` Paul Eggleton
2013-08-13 14:18 ` [PATCH 2/2] taskdata: report close matches with NoProvider errors Paul Eggleton

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.