Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH 0/4] bitbake-layers minor improvements
@ 2011-08-12 16:13 Paul Eggleton
  2011-08-12 16:13 ` [PATCH 1/4] bitbake-layers: improve default command help Paul Eggleton
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Paul Eggleton @ 2011-08-12 16:13 UTC (permalink / raw)
  To: bitbake-devel

Several improvements to the help and show_layers function in
bitbake-layers.

The changes are available (against Poky, but apply cleanly against bitbake
master with -p2) at:
  git://git.pokylinux.org/poky-contrib paule/bitbake-layers-3
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=paule/bitbake-layers-3

Paul Eggleton (4):
  bitbake-layers: improve default command help
  bitbake-layers: show help with no command specified
  bitbake-layers: use logger.plain instead of info
  bitbake-layers: extend show_layers

 bitbake/bin/bitbake-layers |   89 ++++++++++++++++++++++++++++++-------------
 1 files changed, 62 insertions(+), 27 deletions(-)

-- 
1.7.4.1




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

* [PATCH 1/4] bitbake-layers: improve default command help
  2011-08-12 16:13 [PATCH 0/4] bitbake-layers minor improvements Paul Eggleton
@ 2011-08-12 16:13 ` Paul Eggleton
  2011-08-12 16:13 ` [PATCH 2/4] bitbake-layers: show help with no command specified Paul Eggleton
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Paul Eggleton @ 2011-08-12 16:13 UTC (permalink / raw)
  To: bitbake-devel

Improve default help output and make unrecognised commands print it out
rather than just an error.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 bitbake/bin/bitbake-layers |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
index d9f95d1..0900d00 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -76,16 +76,36 @@ class Commands(cmd.Cmd):
         if not self.cooker_data:
             self.prepare_cooker()
 
+    def default(self, line):
+        """Handle unrecognised commands"""
+        sys.stderr.write("Unrecognised command or option\n")
+        self.do_help('')
+
+    def do_help(self, topic):
+        """display general help or help on a specified command"""
+        if topic:
+            sys.stdout.write('%s: ' % topic)
+            cmd.Cmd.do_help(self,topic)
+        else:
+            sys.stdout.write("usage: bitbake-layers <command> [arguments]\n\n")
+            sys.stdout.write("Available commands:\n")
+            procnames = self.get_names()
+            for procname in procnames:
+                if procname[:3] == 'do_':
+                    sys.stdout.write("  %s\n" % procname[3:])
+                    doc = getattr(self, procname).__doc__
+                    if doc:
+                        sys.stdout.write("    %s\n" % doc.splitlines()[0])
+
     def do_show_layers(self, args):
-        """show_layers: shows current configured layers"""
+        """show current configured layers"""
         self.check_prepare_cooker()
         logger.info(str(self.config_data.getVar('BBLAYERS', True)))
 
     def do_show_overlayed(self, args):
-        """show_overlayed: list overlayed recipes (where there is a recipe in another
-layer that has a higher layer priority)
+        """list overlayed recipes (where there is a recipe in another layer that has a higher layer priority)
 
-syntax: show_overlayed
+usage: show_overlayed
 
 Highest priority recipes are listed with the recipes they overlay as subitems.
 """
@@ -100,9 +120,9 @@ Highest priority recipes are listed with the recipes they overlay as subitems.
             logger.info('No overlayed recipes found')
 
     def do_flatten(self, args):
-        """flatten: flattens layer configuration into a separate output directory.
+        """flattens layer configuration into a separate output directory.
 
-syntax: flatten <outputdir>
+usage: flatten <outputdir>
 
 Takes the current layer configuration and builds a "flattened" directory
 containing the contents of all layers, with any overlayed recipes removed
@@ -175,9 +195,9 @@ cleanup may still be necessary afterwards, in particular:
         recipefile.writelines(appendfile.readlines())
 
     def do_show_appends(self, args):
-        """show_appends: List bbappend files and recipe files they apply to
+        """list bbappend files and recipe files they apply to
 
-syntax: show_appends
+usage: show_appends
 
 Recipes are listed with the bbappends that apply to them as subitems.
 """
-- 
1.7.4.1




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

* [PATCH 2/4] bitbake-layers: show help with no command specified
  2011-08-12 16:13 [PATCH 0/4] bitbake-layers minor improvements Paul Eggleton
  2011-08-12 16:13 ` [PATCH 1/4] bitbake-layers: improve default command help Paul Eggleton
@ 2011-08-12 16:13 ` Paul Eggleton
  2011-08-12 16:13 ` [PATCH 3/4] bitbake-layers: use logger.plain instead of info Paul Eggleton
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Paul Eggleton @ 2011-08-12 16:13 UTC (permalink / raw)
  To: bitbake-devel

Instead of running show_appends when no command is specified, show the
default help text. Running show_appends by default made sense previously
when that was the only real command provided, but now we have several
useful commands implemented.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 bitbake/bin/bitbake-layers |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
index 0900d00..2845ae5 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -2,9 +2,7 @@
 
 # This script has subcommands which operate against your bitbake layers, either
 # displaying useful information, or acting against them.
-# Currently, it only provides a show_appends command, which shows you what
-# bbappends are in effect, and warns you if you have appends which are not being
-# utilized.
+# See the help output for details on available commands.
 
 import cmd
 import logging
@@ -23,7 +21,6 @@ from bb.cooker import state
 
 
 logger = logging.getLogger('BitBake')
-default_cmd = 'show_appends'
 
 
 def main(args):
@@ -34,7 +31,7 @@ def main(args):
     if args:
         cmds.onecmd(' '.join(args))
     else:
-        cmds.onecmd(default_cmd)
+        cmds.do_help('')
     return cmds.returncode
 
 
-- 
1.7.4.1




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

* [PATCH 3/4] bitbake-layers: use logger.plain instead of info
  2011-08-12 16:13 [PATCH 0/4] bitbake-layers minor improvements Paul Eggleton
  2011-08-12 16:13 ` [PATCH 1/4] bitbake-layers: improve default command help Paul Eggleton
  2011-08-12 16:13 ` [PATCH 2/4] bitbake-layers: show help with no command specified Paul Eggleton
@ 2011-08-12 16:13 ` Paul Eggleton
  2011-08-12 16:20   ` Paul Eggleton
  2011-08-12 16:13 ` [PATCH 4/4] bitbake-layers: extend show_layers Paul Eggleton
  2011-08-15  8:31 ` [PATCH 0/4] bitbake-layers minor improvements Richard Purdie
  4 siblings, 1 reply; 7+ messages in thread
From: Paul Eggleton @ 2011-08-12 16:13 UTC (permalink / raw)
  To: bitbake-devel

The INFO: prefix makes sense in bitbake itself but in bitbake-layers is
just noise. Changing this exposed the fact that the logger was not being
set up correctly (which should be done anyway to correctly support
logging from BitBake), so this has also been fixed.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 bitbake/bin/bitbake-layers |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
index 2845ae5..aea8f93 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -24,7 +24,12 @@ logger = logging.getLogger('BitBake')
 
 
 def main(args):
-    logging.basicConfig(format='%(levelname)s: %(message)s')
+    # Set up logging
+    console = logging.StreamHandler(sys.stdout)
+    format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
+    console.setFormatter(format)
+    logger.addHandler(console)
+
     bb.utils.clean_environment()
 
     cmds = Commands()
@@ -97,7 +102,7 @@ class Commands(cmd.Cmd):
     def do_show_layers(self, args):
         """show current configured layers"""
         self.check_prepare_cooker()
-        logger.info(str(self.config_data.getVar('BBLAYERS', True)))
+        logger.plain(str(self.config_data.getVar('BBLAYERS', True)))
 
     def do_show_overlayed(self, args):
         """list overlayed recipes (where there is a recipe in another layer that has a higher layer priority)
@@ -108,13 +113,13 @@ Highest priority recipes are listed with the recipes they overlay as subitems.
 """
         self.check_prepare_cooker()
         if self.cooker.overlayed:
-            logger.info('Overlayed recipes:')
+            logger.plain('Overlayed recipes:')
             for f in self.cooker.overlayed.iterkeys():
-                logger.info('%s' % f)
+                logger.plain('%s' % f)
                 for of in self.cooker.overlayed[f]:
-                    logger.info('  %s' % of)
+                    logger.plain('  %s' % of)
         else:
-            logger.info('No overlayed recipes found')
+            logger.plain('No overlayed recipes found')
 
     def do_flatten(self, args):
         """flattens layer configuration into a separate output directory.
@@ -151,12 +156,12 @@ cleanup may still be necessary afterwards, in particular:
                     if of.startswith(layer):
                         overlayed.append(of)
 
-            logger.info('Copying files from %s...' % layer )
+            logger.plain('Copying files from %s...' % layer )
             for root, dirs, files in os.walk(layer):
                 for f1 in files:
                     f1full = os.sep.join([root, f1])
                     if f1full in overlayed:
-                        logger.info('  Skipping overlayed file %s' % f1full )
+                        logger.plain('  Skipping overlayed file %s' % f1full )
                     else:
                         ext = os.path.splitext(f1)[1]
                         if ext != '.bbappend':
@@ -165,7 +170,7 @@ cleanup may still be necessary afterwards, in particular:
                             bb.utils.mkdirhier(os.path.dirname(fdest))
                             if os.path.exists(fdest):
                                 if f1 == 'layer.conf' and root.endswith('/conf'):
-                                    logger.info('  Skipping layer config file %s' % f1full )
+                                    logger.plain('  Skipping layer config file %s' % f1full )
                                     continue
                                 else:
                                     logger.warn('Overwriting file %s', fdest)
@@ -174,7 +179,7 @@ cleanup may still be necessary afterwards, in particular:
                                 if f1 in self.cooker_data.appends:
                                     appends = self.cooker_data.appends[f1]
                                     if appends:
-                                        logger.info('  Applying appends to %s' % fdest )
+                                        logger.plain('  Applying appends to %s' % fdest )
                                         for appendname in appends:
                                             self.apply_append(appendname, fdest)
 
@@ -200,10 +205,10 @@ Recipes are listed with the bbappends that apply to them as subitems.
 """
         self.check_prepare_cooker()
         if not self.cooker_data.appends:
-            logger.info('No append files found')
+            logger.plain('No append files found')
             return
 
-        logger.info('State of append files:')
+        logger.plain('State of append files:')
 
         pnlist = list(self.cooker_data.pkg_pn.keys())
         pnlist.sort()
@@ -232,9 +237,9 @@ Recipes are listed with the bbappends that apply to them as subitems.
         appended, missing = self.get_appends_for_files(filenames)
         if appended:
             for basename, appends in appended:
-                logger.info('%s%s:', basename, name_suffix)
+                logger.plain('%s%s:', basename, name_suffix)
                 for append in appends:
-                    logger.info('  %s', append)
+                    logger.plain('  %s', append)
 
             if best_filename:
                 if best_filename in missing:
-- 
1.7.4.1




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

* [PATCH 4/4] bitbake-layers: extend show_layers
  2011-08-12 16:13 [PATCH 0/4] bitbake-layers minor improvements Paul Eggleton
                   ` (2 preceding siblings ...)
  2011-08-12 16:13 ` [PATCH 3/4] bitbake-layers: use logger.plain instead of info Paul Eggleton
@ 2011-08-12 16:13 ` Paul Eggleton
  2011-08-15  8:31 ` [PATCH 0/4] bitbake-layers minor improvements Richard Purdie
  4 siblings, 0 replies; 7+ messages in thread
From: Paul Eggleton @ 2011-08-12 16:13 UTC (permalink / raw)
  To: bitbake-devel

Make show_layers print layer name, path, and priority in a simple table
rather than just the value of BBLAYERS.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 bitbake/bin/bitbake-layers |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
index aea8f93..ce6a03e 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -102,7 +102,20 @@ class Commands(cmd.Cmd):
     def do_show_layers(self, args):
         """show current configured layers"""
         self.check_prepare_cooker()
-        logger.plain(str(self.config_data.getVar('BBLAYERS', True)))
+        logger.plain('')
+        logger.plain("%s  %s  %s" % ("layer".ljust(20), "path".ljust(40), "priority"))
+        logger.plain('=' * 74)
+        layerdirs = str(self.config_data.getVar('BBLAYERS', True)).split()
+        for layerdir in layerdirs:
+            layername = '?'
+            layerpri = 0
+            for layer, _, regex, pri in self.cooker.status.bbfile_config_priorities:
+                if regex.match(os.path.join(layerdir, 'test')):
+                    layername = layer
+                    layerpri = pri
+                    break
+
+            logger.plain("%s  %s  %d" % (layername.ljust(20), layerdir.ljust(40), layerpri))
 
     def do_show_overlayed(self, args):
         """list overlayed recipes (where there is a recipe in another layer that has a higher layer priority)
-- 
1.7.4.1




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

* Re: [PATCH 3/4] bitbake-layers: use logger.plain instead of info
  2011-08-12 16:13 ` [PATCH 3/4] bitbake-layers: use logger.plain instead of info Paul Eggleton
@ 2011-08-12 16:20   ` Paul Eggleton
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Eggleton @ 2011-08-12 16:20 UTC (permalink / raw)
  To: bitbake-devel

On Friday 12 August 2011 17:13:58 Paul Eggleton wrote:
> +    # Set up logging
> +    console = logging.StreamHandler(sys.stdout)
> +    format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")

Forgot to mention in the cover: when Richard's logging changes get merged this 
code will need the additional "bb.msg.addDefaultlogFilter(console)" line added 
as well.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



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

* Re: [PATCH 0/4] bitbake-layers minor improvements
  2011-08-12 16:13 [PATCH 0/4] bitbake-layers minor improvements Paul Eggleton
                   ` (3 preceding siblings ...)
  2011-08-12 16:13 ` [PATCH 4/4] bitbake-layers: extend show_layers Paul Eggleton
@ 2011-08-15  8:31 ` Richard Purdie
  4 siblings, 0 replies; 7+ messages in thread
From: Richard Purdie @ 2011-08-15  8:31 UTC (permalink / raw)
  To: Paul Eggleton; +Cc: bitbake-devel

On Fri, 2011-08-12 at 17:13 +0100, Paul Eggleton wrote:
> Several improvements to the help and show_layers function in
> bitbake-layers.
> 
> The changes are available (against Poky, but apply cleanly against bitbake
> master with -p2) at:
>   git://git.pokylinux.org/poky-contrib paule/bitbake-layers-3
>   http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=paule/bitbake-layers-3
> 
> Paul Eggleton (4):
>   bitbake-layers: improve default command help
>   bitbake-layers: show help with no command specified
>   bitbake-layers: use logger.plain instead of info
>   bitbake-layers: extend show_layers

Merged to master, thanks (with the log change issue handled).

Cheers,

Richard




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

end of thread, other threads:[~2011-08-15  8:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-12 16:13 [PATCH 0/4] bitbake-layers minor improvements Paul Eggleton
2011-08-12 16:13 ` [PATCH 1/4] bitbake-layers: improve default command help Paul Eggleton
2011-08-12 16:13 ` [PATCH 2/4] bitbake-layers: show help with no command specified Paul Eggleton
2011-08-12 16:13 ` [PATCH 3/4] bitbake-layers: use logger.plain instead of info Paul Eggleton
2011-08-12 16:20   ` Paul Eggleton
2011-08-12 16:13 ` [PATCH 4/4] bitbake-layers: extend show_layers Paul Eggleton
2011-08-15  8:31 ` [PATCH 0/4] bitbake-layers minor improvements Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox