Patchwork [bitbake-devel,1/2] runqueue: report close matches for an invalid task name

login
register
mail settings
Submitter Paul Eggleton
Date Aug. 13, 2013, 2:18 p.m.
Message ID <3da24015e63e0ed7223d668790027ede24a5c02e.1376403450.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/55543/
State New
Headers show

Comments

Paul Eggleton - Aug. 13, 2013, 2:18 p.m.
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(-)
Richard Purdie - Aug. 13, 2013, 8:18 p.m.
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
Paul Eggleton - Aug. 13, 2013, 8:46 p.m.
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

Patch

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]]