Skip to contentSkip to conversation

devtool: code style fixes

PATCH In review Markus Lehtonen 2 participants 14 messages May 11, 2015 – May 18, 2015

lore
Share & tools
lore
#0 lore raw

cover devtool: code style fixes

This patchset contains numerous small non-functional changes to fix some style errors and to improve the readability of the devtool code.

Markus Lehtonen (11):
devtool: standard plugins: add missing docstrings
devtool: standard plugins: remove unused import
devtool: standard plugins: rename usunused variable
devtool: lib: add missing docstrings
devtool: lib: remove unnecessary re-import
devtool: lib: wrap long lines in code
devtool: deploy plugin: fix bad indentation
devtool: deploy plugin: add missing docstrings
devtool: deploy plugin: remove unnecessary re-import
devtool: deploy plugin: rename unused variables
devtool: deploy plugin: wrap long lines in code

 scripts/lib/devtool/__init__.py |  15 ++++--
 scripts/lib/devtool/deploy.py   | 112 ++++++++++++++++++++++++++++------------
 scripts/lib/devtool/standard.py |  23 +++++++--
 3 files changed, 110 insertions(+), 40 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/11 devtool: standard plugins: add missing docstrings

---
 scripts/lib/devtool/standard.py | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
scripts/lib/devtool/standard.py +19 -1
index 81a44d4..55580ee 100644
@@ -14,6 +14,7 @@
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+"""Devtool standard plugins"""
 
 import os
 import sys
@@ -29,10 +30,12 @@ from devtool import exec_build_env_command, setup_tinfoil
 logger = logging.getLogger('devtool')
 
 def plugin_init(pluginlist):
+    """Plugin initialization"""
     pass
 
 
 def add(args, config, basepath, workspace):
+    """Entry point for the devtool 'add' subcommand"""
     import bb
     import oe.recipeutils
 
@@ -120,6 +123,7 @@ def add(args, config, basepath, workspace):
 
 
 def _check_compatible_recipe(pn, d):
+    """Check if the recipe is supported by devtool"""
     if pn == 'perf':
         logger.error("The perf recipe does not actually check out source and thus cannot be supported by this tool")
         return False
@@ -152,6 +156,7 @@ def _check_compatible_recipe(pn, d):
 
 
 def _get_recipe_file(cooker, pn):
+    """Find recipe file corresponding a package name"""
     import oe.recipeutils
     recipefile = oe.recipeutils.pn_to_recipe(cooker, pn)
     if not recipefile:
@@ -178,6 +183,7 @@ def _parse_recipe(config, tinfoil, pn, appends):
                                        tinfoil.config_data)
 
 def extract(args, config, basepath, workspace):
+    """Entry point for the devtool 'extract' subcommand"""
     import bb
 
     tinfoil = setup_tinfoil()
@@ -195,9 +201,11 @@ def extract(args, config, basepath, workspace):
 
 
 def _extract_source(srctree, keep_temp, devbranch, d):
+    """Extract sources of a recipe"""
     import bb.event
 
     def eventfilter(name, handler, event, d):
+        """Bitbake event filter for devtool extract operation"""
         if name == 'base_eventhandler':
             return True
         else:
@@ -247,6 +255,7 @@ def _extract_source(srctree, keep_temp, devbranch, d):
         # are to handle e.g. linux-yocto's extra tasks
         executed = []
         def exec_task_func(func, report):
+            """Run specific bitbake task for a recipe"""
             if not func in executed:
                 deps = crd.getVarFlag(func, 'deps')
                 if deps:
@@ -319,12 +328,15 @@ def _extract_source(srctree, keep_temp, devbranch, d):
     return initial_rev
 
 def _add_md5(config, recipename, filename):
+    """Record checksum of a recipe to the md5-file of the workspace"""
     import bb.utils
     md5 = bb.utils.md5_file(filename)
     with open(os.path.join(config.workspace_path, '.devtool_md5'), 'a') as f:
         f.write('%s|%s|%s\n' % (recipename, os.path.relpath(filename, config.workspace_path), md5))
 
 def _check_preserve(config, recipename):
+    """Check if a recipe was manually changed and needs to be saved in 'attic'
+       directory"""
     import bb.utils
     origfile = os.path.join(config.workspace_path, '.devtool_md5')
     newfile = os.path.join(config.workspace_path, '.devtool_md5_new')
@@ -358,6 +370,7 @@ def _check_preserve(config, recipename):
 
 
 def modify(args, config, basepath, workspace):
+    """Entry point for the devtool 'modify' subcommand"""
     import bb
     import oe.recipeutils
 
@@ -457,6 +470,7 @@ def modify(args, config, basepath, workspace):
 
 
 def update_recipe(args, config, basepath, workspace):
+    """Entry point for the devtool 'update-recipe' subcommand"""
     if not args.recipename in workspace:
         logger.error("no recipe named %s in your workspace" % args.recipename)
         return -1
@@ -487,7 +501,7 @@ def update_recipe(args, config, basepath, workspace):
         mode = args.mode
 
     def remove_patches(srcuri, patchlist):
-        # Remove any patches that we don't need
+        """Remove patches"""
         updated = False
         for patch in patchlist:
             patchfile = os.path.basename(patch)
@@ -639,6 +653,7 @@ def update_recipe(args, config, basepath, workspace):
 
 
 def status(args, config, basepath, workspace):
+    """Entry point for the devtool 'status' subcommand"""
     if workspace:
         for recipe, value in workspace.iteritems():
             print("%s: %s" % (recipe, value))
@@ -648,6 +663,7 @@ def status(args, config, basepath, workspace):
 
 
 def reset(args, config, basepath, workspace):
+    """Entry point for the devtool 'reset' subcommand"""
     import bb.utils
     if args.recipename:
         if args.all:
@@ -689,6 +705,7 @@ def reset(args, config, basepath, workspace):
 
 
 def build(args, config, basepath, workspace):
+    """Entry point for the devtool 'build' subcommand"""
     import bb
     if not args.recipename in workspace:
         logger.error("no recipe named %s in your workspace" % args.recipename)
@@ -700,6 +717,7 @@ def build(args, config, basepath, workspace):
 
 
 def register_commands(subparsers, context):
+    """Register devtool subcommands from this plugin"""
     parser_add = subparsers.add_parser('add', help='Add a new recipe',
                                        description='Adds a new recipe')
     parser_add.add_argument('recipename', help='Name for new recipe to add')
Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/11 devtool: standard plugins: rename usunused variable

In reply to Markus Lehtonen
---
 scripts/lib/devtool/standard.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/lib/devtool/standard.py +1 -1
index 614bcdb..2a483cf 100644
@@ -97,7 +97,7 @@ def add(args, config, basepath, workspace):
         source = srctree
     if args.version:
         extracmdopts += ' -V %s' % args.version
-    stdout, stderr = exec_build_env_command(config.init_path, basepath, 'recipetool --color=%s create -o %s "%s" %s' % (color, recipefile, source, extracmdopts))
+    stdout, _ = exec_build_env_command(config.init_path, basepath, 'recipetool --color=%s create -o %s "%s" %s' % (color, recipefile, source, extracmdopts))
     logger.info('Recipe %s has been automatically created; further editing may be required to make it fully functional' % recipefile)
 
     _add_md5(config, args.recipename, recipefile)
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/11 devtool: standard plugins: remove unused import

In reply to Markus Lehtonen
---
 scripts/lib/devtool/standard.py | 1 -
 1 file changed, 1 deletion(-)
scripts/lib/devtool/standard.py +0 -1
index 55580ee..614bcdb 100644
@@ -20,7 +20,6 @@ import os
 import sys
 import re
 import shutil
-import glob
 import tempfile
 import logging
 import argparse
Signature · 1 line
2.1.4
#4 lore raw

PATCH 4/11 devtool: lib: add missing docstrings

In reply to Markus Lehtonen
---
 scripts/lib/devtool/__init__.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/lib/devtool/__init__.py +4 -1
index 78ae0aa..00594eb 100644
@@ -16,7 +16,7 @@
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
+"""Devtool plugins module"""
 
 import os
 import sys
@@ -26,6 +26,7 @@ import logging
 logger = logging.getLogger('devtool')
 
 def exec_build_env_command(init_path, builddir, cmd, watch=False, **options):
+    """Run a program in bitbake build context"""
     import bb
     if not 'cwd' in options:
         options["cwd"] = builddir
@@ -49,6 +50,7 @@ def exec_build_env_command(init_path, builddir, cmd, watch=False, **options):
         return bb.process.run('%s%s' % (init_prefix, cmd), **options)
 
 def exec_watch(cmd, **options):
+    """Run program with stdout shown on sys.stdout"""
     if isinstance(cmd, basestring) and not "shell" in options:
         options["shell"] = True
 
@@ -68,6 +70,7 @@ def exec_watch(cmd, **options):
     return buf
 
 def setup_tinfoil():
+    """Initialize tinfoil api from bitbake"""
     import scriptpath
     bitbakepath = scriptpath.add_bitbake_lib_path()
     if not bitbakepath:
Signature · 1 line
2.1.4
#5 lore raw

PATCH 5/11 devtool: lib: remove unnecessary re-import

In reply to Markus Lehtonen
---
 scripts/lib/devtool/__init__.py | 1 -
 1 file changed, 1 deletion(-)
scripts/lib/devtool/__init__.py +0 -1
index 00594eb..8866512 100644
@@ -78,7 +78,6 @@ def setup_tinfoil():
         sys.exit(1)
 
     import bb.tinfoil
-    import logging
     tinfoil = bb.tinfoil.Tinfoil()
     tinfoil.prepare(False)
     tinfoil.logger.setLevel(logging.WARNING)
Signature · 1 line
2.1.4
#6 lore raw

PATCH 6/11 devtool: lib: wrap long lines in code

In reply to Markus Lehtonen
---
 scripts/lib/devtool/__init__.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
scripts/lib/devtool/__init__.py +6 -3
index 8866512..676bc52 100644
@@ -36,14 +36,16 @@ def exec_build_env_command(init_path, builddir, cmd, watch=False, **options):
         # the executable to bash to correctly set things up
         if not 'executable' in options:
             options['executable'] = 'bash'
-        logger.debug('Executing command: "%s" using init path %s' % (cmd, init_path))
+        logger.debug('Executing command: "%s" using init path %s' %
+                     (cmd, init_path))
         init_prefix = '. %s %s > /dev/null && ' % (init_path, builddir)
     else:
         logger.debug('Executing command "%s"' % cmd)
         init_prefix = ''
     if watch:
         if sys.stdout.isatty():
-            # Fool bitbake into thinking it's outputting to a terminal (because it is, indirectly)
+            # Fool bitbake into thinking it's outputting to a terminal
+            # (because it is, indirectly)
             cmd = 'script -q -c "%s" /dev/null' % cmd
         return exec_watch('%s%s' % (init_prefix, cmd), **options)
     else:
@@ -74,7 +76,8 @@ def setup_tinfoil():
     import scriptpath
     bitbakepath = scriptpath.add_bitbake_lib_path()
     if not bitbakepath:
-        logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
+        logger.error("Unable to find bitbake by searching parent directory of "
+                     "this script or PATH")
         sys.exit(1)
 
     import bb.tinfoil
Signature · 1 line
2.1.4
#7 lore raw

PATCH 7/11 devtool: deploy plugin: fix bad indentation

In reply to Markus Lehtonen
---
 scripts/lib/devtool/deploy.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/lib/devtool/deploy.py +2 -2
index f016b23..62c97fb 100644
@@ -91,8 +91,8 @@ def undeploy(args, config, basepath, workspace):
 
     deploy_file = os.path.join(basepath, 'target_deploy', args.target, args.recipename + '.list')
     if not os.path.exists(deploy_file):
-         logger.error('%s has not been deployed' % args.recipename)
-         return -1
+        logger.error('%s has not been deployed' % args.recipename)
+        return -1
 
     if args.dry_run:
         print('Previously deployed files to be un-deployed for %s on target %s:' % (args.recipename, args.target))
Signature · 1 line
2.1.4
#8 lore raw

PATCH 8/11 devtool: deploy plugin: add missing docstrings

In reply to Markus Lehtonen
---
 scripts/lib/devtool/deploy.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/lib/devtool/deploy.py +5 -1
index 62c97fb..b569398 100644
@@ -14,6 +14,7 @@
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+"""Devtool plugin containing the deploy subcommands"""
 
 import os
 import subprocess
@@ -23,10 +24,12 @@ from devtool import exec_build_env_command
 logger = logging.getLogger('devtool')
 
 def plugin_init(pluginlist):
+    """Plugin initialization"""
     pass
 
 
 def deploy(args, config, basepath, workspace):
+    """Entry point for the devtool 'deploy' subcommand"""
     import re
     from devtool import exec_build_env_command
 
@@ -88,7 +91,7 @@ def deploy(args, config, basepath, workspace):
     return 0
 
 def undeploy(args, config, basepath, workspace):
-
+    """Entry point for the devtool 'undeploy' subcommand"""
     deploy_file = os.path.join(basepath, 'target_deploy', args.target, args.recipename + '.list')
     if not os.path.exists(deploy_file):
         logger.error('%s has not been deployed' % args.recipename)
@@ -123,6 +126,7 @@ def undeploy(args, config, basepath, workspace):
 
 
 def register_commands(subparsers, context):
+    """Register devtool subcommands from the deploy plugin"""
     parser_deploy = subparsers.add_parser('deploy-target', help='Deploy recipe output files to live target machine')
     parser_deploy.add_argument('recipename', help='Recipe to deploy')
     parser_deploy.add_argument('target', help='Live target machine running an ssh server: user@hostname[:destdir]')
Signature · 1 line
2.1.4
#9 lore raw

PATCH 9/11 devtool: deploy plugin: remove unnecessary re-import

In reply to Markus Lehtonen
---
 scripts/lib/devtool/deploy.py | 1 -
 1 file changed, 1 deletion(-)
scripts/lib/devtool/deploy.py +0 -1
index b569398..8637f19 100644
@@ -31,7 +31,6 @@ def plugin_init(pluginlist):
 def deploy(args, config, basepath, workspace):
     """Entry point for the devtool 'deploy' subcommand"""
     import re
-    from devtool import exec_build_env_command
 
     if not args.recipename in workspace:
         logger.error("no recipe named %s in your workspace" % args.recipename)
Signature · 1 line
2.1.4
#10 lore raw

PATCH 10/11 devtool: deploy plugin: rename unused variables

In reply to Markus Lehtonen
---
 scripts/lib/devtool/deploy.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/lib/devtool/deploy.py +2 -2
index 8637f19..078c74b 100644
@@ -45,7 +45,7 @@ def deploy(args, config, basepath, workspace):
     deploy_dir = os.path.join(basepath, 'target_deploy', args.target)
     deploy_file = os.path.join(deploy_dir, args.recipename + '.list')
 
-    stdout, stderr = exec_build_env_command(config.init_path, basepath, 'bitbake -e %s' % args.recipename, shell=True)
+    stdout, _ = exec_build_env_command(config.init_path, basepath, 'bitbake -e %s' % args.recipename, shell=True)
     recipe_outdir = re.search(r'^D="(.*)"', stdout, re.MULTILINE).group(1)
     if not os.path.exists(recipe_outdir) or not os.listdir(recipe_outdir):
         logger.error('No files to deploy - have you built the %s recipe? If so, the install step has not installed any files.' % args.recipename)
@@ -53,7 +53,7 @@ def deploy(args, config, basepath, workspace):
 
     if args.dry_run:
         print('Files to be deployed for %s on target %s:' % (args.recipename, args.target))
-        for root, dirs, files in os.walk(recipe_outdir):
+        for root, _, files in os.walk(recipe_outdir):
             for fn in files:
                 print('  %s' % os.path.join(destdir, os.path.relpath(root, recipe_outdir), fn))
         return 0
Signature · 1 line
2.1.4
#11 lore raw

PATCH 11/11 devtool: deploy plugin: wrap long lines in code

In reply to Markus Lehtonen
---
 scripts/lib/devtool/deploy.py | 99 +++++++++++++++++++++++++++++++------------
 1 file changed, 72 insertions(+), 27 deletions(-)
scripts/lib/devtool/deploy.py +72 -27
index 078c74b..f6ae433 100644
@@ -45,17 +45,23 @@ def deploy(args, config, basepath, workspace):
     deploy_dir = os.path.join(basepath, 'target_deploy', args.target)
     deploy_file = os.path.join(deploy_dir, args.recipename + '.list')
 
-    stdout, _ = exec_build_env_command(config.init_path, basepath, 'bitbake -e %s' % args.recipename, shell=True)
+    stdout, _ = exec_build_env_command(config.init_path, basepath,
+                                       'bitbake -e %s' % args.recipename,
+                                       shell=True)
     recipe_outdir = re.search(r'^D="(.*)"', stdout, re.MULTILINE).group(1)
     if not os.path.exists(recipe_outdir) or not os.listdir(recipe_outdir):
-        logger.error('No files to deploy - have you built the %s recipe? If so, the install step has not installed any files.' % args.recipename)
+        logger.error('No files to deploy - have you built the %s recipe? If '
+                     'so, the install step has not installed any files.' %
+                     args.recipename)
         return -1
 
     if args.dry_run:
-        print('Files to be deployed for %s on target %s:' % (args.recipename, args.target))
+        print('Files to be deployed for %s on target %s:' %
+              (args.recipename, args.target))
         for root, _, files in os.walk(recipe_outdir):
             for fn in files:
-                print('  %s' % os.path.join(destdir, os.path.relpath(root, recipe_outdir), fn))
+                print('  %s' % os.path.join(
+                        destdir, os.path.relpath(root, recipe_outdir), fn))
         return 0
 
     if os.path.exists(deploy_file):
@@ -65,12 +71,16 @@ def deploy(args, config, basepath, workspace):
 
     extraoptions = ''
     if args.no_host_check:
-        extraoptions += '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
+        extraoptions += '-o UserKnownHostsFile=/dev/null'
+        extraoptions += ' -o StrictHostKeyChecking=no'
     if not args.show_status:
         extraoptions += ' -q'
-    ret = subprocess.call('scp -r %s %s/* %s:%s' % (extraoptions, recipe_outdir, args.target, destdir), shell=True)
+    ret = subprocess.call('scp -r %s %s/* %s:%s' %
+                          (extraoptions, recipe_outdir, args.target, destdir),
+                          shell=True)
     if ret != 0:
-        logger.error('Deploy failed - rerun with -s to get a complete error message')
+        logger.error('Deploy failed - rerun with -s to get a complete error '
+                     'message')
         return ret
 
     logger.info('Successfully deployed %s' % recipe_outdir)
@@ -81,7 +91,8 @@ def deploy(args, config, basepath, workspace):
     files_list = []
     for root, _, files in os.walk(recipe_outdir):
         for filename in files:
-            filename = os.path.relpath(os.path.join(root, filename), recipe_outdir)
+            filename = os.path.relpath(os.path.join(root, filename),
+                                       recipe_outdir)
             files_list.append(os.path.join(destdir, filename))
 
     with open(deploy_file, 'w') as fobj:
@@ -91,13 +102,15 @@ def deploy(args, config, basepath, workspace):
 
 def undeploy(args, config, basepath, workspace):
     """Entry point for the devtool 'undeploy' subcommand"""
-    deploy_file = os.path.join(basepath, 'target_deploy', args.target, args.recipename + '.list')
+    deploy_file = os.path.join(basepath, 'target_deploy', args.target,
+                               args.recipename + '.list')
     if not os.path.exists(deploy_file):
         logger.error('%s has not been deployed' % args.recipename)
         return -1
 
     if args.dry_run:
-        print('Previously deployed files to be un-deployed for %s on target %s:' % (args.recipename, args.target))
+        print('Previously deployed files to be un-deployed for %s on target '
+              '%s:' % (args.recipename, args.target))
         with open(deploy_file, 'r') as f:
             for line in f:
                 print('  %s' % line.rstrip())
@@ -105,39 +118,71 @@ def undeploy(args, config, basepath, workspace):
 
     extraoptions = ''
     if args.no_host_check:
-        extraoptions += '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
+        extraoptions += '-o UserKnownHostsFile=/dev/null '
+        extraoptions += ' -o StrictHostKeyChecking=no'
     if not args.show_status:
         extraoptions += ' -q'
 
-    ret = subprocess.call("scp %s %s %s:/tmp" % (extraoptions, deploy_file, args.target), shell=True)
+    ret = subprocess.call("scp %s %s %s:/tmp" %
+                          (extraoptions, deploy_file, args.target), shell=True)
     if ret != 0:
-        logger.error('Failed to copy file list to %s - rerun with -s to get a complete error message' % args.target)
+        logger.error('Failed to copy file list to %s - rerun with -s to get a '
+                     'complete error message' % args.target)
         return -1
 
-    ret = subprocess.call("ssh %s %s 'xargs -n1 rm -f </tmp/%s'" % (extraoptions, args.target, os.path.basename(deploy_file)), shell=True)
+    ret = subprocess.call(
+            "ssh %s %s 'xargs -n1 rm -f </tmp/%s'" %
+            (extraoptions, args.target, os.path.basename(deploy_file)),
+            shell=True)
     if ret == 0:
         logger.info('Successfully undeployed %s' % args.recipename)
         os.remove(deploy_file)
     else:
-        logger.error('Undeploy failed - rerun with -s to get a complete error message')
+        logger.error('Undeploy failed - rerun with -s to get a complete error '
+                     'message')
 
     return ret
 
 
 def register_commands(subparsers, context):
     """Register devtool subcommands from the deploy plugin"""
-    parser_deploy = subparsers.add_parser('deploy-target', help='Deploy recipe output files to live target machine')
-    parser_deploy.add_argument('recipename', help='Recipe to deploy')
-    parser_deploy.add_argument('target', help='Live target machine running an ssh server: user@hostname[:destdir]')
-    parser_deploy.add_argument('-c', '--no-host-check', help='Disable ssh host key checking', action='store_true')
-    parser_deploy.add_argument('-s', '--show-status', help='Show progress/status output', action='store_true')
-    parser_deploy.add_argument('-n', '--dry-run', help='List files to be deployed only', action='store_true')
+    parser_deploy = subparsers.add_parser(
+            'deploy-target',
+            help='Deploy recipe output files to live target machine')
+    parser_deploy.add_argument(
+            'recipename',
+            help='Recipe to deploy')
+    parser_deploy.add_argument(
+            'target',
+            help='Live target machine running an ssh server: '
+                 'user@hostname[:destdir]')
+    parser_deploy.add_argument(
+            '-c', '--no-host-check',
+            help='Disable ssh host key checking', action='store_true')
+    parser_deploy.add_argument(
+            '-s', '--show-status',
+            help='Show progress/status output', action='store_true')
+    parser_deploy.add_argument(
+            '-n', '--dry-run',
+            help='List files to be deployed only', action='store_true')
     parser_deploy.set_defaults(func=deploy)
 
-    parser_undeploy = subparsers.add_parser('undeploy-target', help='Undeploy recipe output files in live target machine')
-    parser_undeploy.add_argument('recipename', help='Recipe to undeploy')
-    parser_undeploy.add_argument('target', help='Live target machine running an ssh server: user@hostname')
-    parser_undeploy.add_argument('-c', '--no-host-check', help='Disable ssh host key checking', action='store_true')
-    parser_undeploy.add_argument('-s', '--show-status', help='Show progress/status output', action='store_true')
-    parser_undeploy.add_argument('-n', '--dry-run', help='List files to be undeployed only', action='store_true')
+    parser_undeploy = subparsers.add_parser(
+            'undeploy-target',
+            help='Undeploy recipe output files in live target machine')
+    parser_undeploy.add_argument(
+            'recipename',
+            help='Recipe to undeploy')
+    parser_undeploy.add_argument(
+            'target',
+            help='Live target machine running an ssh server: user@hostname')
+    parser_undeploy.add_argument(
+            '-c', '--no-host-check',
+            help='Disable ssh host key checking', action='store_true')
+    parser_undeploy.add_argument(
+            '-s', '--show-status',
+            help='Show progress/status output', action='store_true')
+    parser_undeploy.add_argument(
+            '-n', '--dry-run',
+            help='List files to be undeployed only', action='store_true')
     parser_undeploy.set_defaults(func=undeploy)
Signature · 1 line
2.1.4
#12 lore raw

Re: [PATCH 11/11] devtool: deploy plugin: wrap long lines in code

Quoted 184 lines · On Monday 11 May 2015 16:17:11 Markus Lehtonen wrote:
---
 scripts/lib/devtool/deploy.py | 99

+++++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 27 deletions(-)

scripts/lib/devtool/deploy.py +0 -2
index 078c74b..f6ae433 100644
@@ -45,17 +45,23 @@ def deploy(args, config, basepath, workspace):
     deploy_dir = os.path.join(basepath, 'target_deploy', args.target)
     deploy_file = os.path.join(deploy_dir, args.recipename + '.list')
 
-    stdout, _ = exec_build_env_command(config.init_path, basepath, 'bitbake
-e %s' % args.recipename, shell=True) +    stdout, _ =

exec_build_env_command(config.init_path, basepath, +
'bitbake -e %s' % args.recipename, +
shell=True)
recipe_outdir = re.search(r'^D="(.*)"', stdout, re.MULTILINE).group(1) if not os.path.exists(recipe_outdir) or not os.listdir(recipe_outdir):
- logger.error('No files to deploy - have you built the %s recipe? If
so, the install step has not installed any files.' % args.recipename) +
logger.error('No files to deploy - have you built the %s recipe? If ' +
'so, the install step has not installed any files.' % + args.recipename)
return -1

if args.dry_run:
- print('Files to be deployed for %s on target %s:' %
(args.recipename, args.target)) + print('Files to be deployed for %s
on target %s:' %

scripts/lib/devtool/deploy.py +1 -1
+              (args.recipename, args.target))
         for root, _, files in os.walk(recipe_outdir):
             for fn in files:
-                print('  %s' % os.path.join(destdir, os.path.relpath(root,

recipe_outdir), fn)) + print(' %s' % os.path.join(
+ destdir, os.path.relpath(root, recipe_outdir), fn))
return 0

if os.path.exists(deploy_file):

scripts/lib/devtool/deploy.py +0 -1
@@ -65,12 +71,16 @@ def deploy(args, config, basepath, workspace):
 
     extraoptions = ''
     if args.no_host_check:
-        extraoptions += '-o UserKnownHostsFile=/dev/null -o

StrictHostKeyChecking=no' + extraoptions += '-o
UserKnownHostsFile=/dev/null'

scripts/lib/devtool/deploy.py +1 -1
+        extraoptions += ' -o StrictHostKeyChecking=no'
     if not args.show_status:
         extraoptions += ' -q'
-    ret = subprocess.call('scp -r %s %s/* %s:%s' % (extraoptions,

recipe_outdir, args.target, destdir), shell=True) + ret =
subprocess.call('scp -r %s %s/* %s:%s' %
+ (extraoptions, recipe_outdir, args.target,
destdir), + shell=True)

     if ret != 0:

- logger.error('Deploy failed - rerun with -s to get a complete error
message') + logger.error('Deploy failed - rerun with -s to get a
complete error ' + 'message')
return ret

logger.info('Successfully deployed %s' % recipe_outdir)

scripts/lib/devtool/deploy.py +0 -2
@@ -81,7 +91,8 @@ def deploy(args, config, basepath, workspace):
     files_list = []
     for root, _, files in os.walk(recipe_outdir):
         for filename in files:
-            filename = os.path.relpath(os.path.join(root, filename),
 recipe_outdir) +            filename = os.path.relpath(os.path.join(root,
 filename), +                                       recipe_outdir)
             files_list.append(os.path.join(destdir, filename))
 
     with open(deploy_file, 'w') as fobj:
@@ -91,13 +102,15 @@ def deploy(args, config, basepath, workspace):
 
 def undeploy(args, config, basepath, workspace):
     """Entry point for the devtool 'undeploy' subcommand"""
-    deploy_file = os.path.join(basepath, 'target_deploy', args.target,
 args.recipename + '.list') +    deploy_file = os.path.join(basepath,

'target_deploy', args.target, +
args.recipename + '.list')
if not os.path.exists(deploy_file):
logger.error('%s has not been deployed' % args.recipename) return -1

if args.dry_run:
- print('Previously deployed files to be un-deployed for %s on target
%s:' % (args.recipename, args.target)) + print('Previously deployed
files to be un-deployed for %s on target ' + '%s:' %
(args.recipename, args.target))
with open(deploy_file, 'r') as f:
for line in f:
print(' %s' % line.rstrip())

scripts/lib/devtool/deploy.py +0 -1
@@ -105,39 +118,71 @@ def undeploy(args, config, basepath, workspace):
 
     extraoptions = ''
     if args.no_host_check:
-        extraoptions += '-o UserKnownHostsFile=/dev/null -o

StrictHostKeyChecking=no' + extraoptions += '-o
UserKnownHostsFile=/dev/null '

scripts/lib/devtool/deploy.py +1 -1
+        extraoptions += ' -o StrictHostKeyChecking=no'
     if not args.show_status:
         extraoptions += ' -q'
 
-    ret = subprocess.call("scp %s %s %s:/tmp" % (extraoptions, deploy_file,

args.target), shell=True) + ret = subprocess.call("scp %s %s %s:/tmp" %
+ (extraoptions, deploy_file, args.target),
shell=True) if ret != 0:
- logger.error('Failed to copy file list to %s - rerun with -s to get
a complete error message' % args.target) + logger.error('Failed to
copy file list to %s - rerun with -s to get a ' +
'complete error message' % args.target)
return -1

- ret = subprocess.call("ssh %s %s 'xargs -n1 rm -f </tmp/%s'" %
(extraoptions, args.target, os.path.basename(deploy_file)), shell=True) +
ret = subprocess.call(

scripts/lib/devtool/deploy.py +3 -1
+            "ssh %s %s 'xargs -n1 rm -f </tmp/%s'" %
+            (extraoptions, args.target, os.path.basename(deploy_file)),
+            shell=True)
     if ret == 0:
         logger.info('Successfully undeployed %s' % args.recipename)
         os.remove(deploy_file)
     else:
-        logger.error('Undeploy failed - rerun with -s to get a complete

error message') + logger.error('Undeploy failed - rerun with -s to
get a complete error ' + 'message')

return ret

def register_commands(subparsers, context):
"""Register devtool subcommands from the deploy plugin"""
- parser_deploy = subparsers.add_parser('deploy-target', help='Deploy
recipe output files to live target machine') - parser_deploy.add_argument('recipename', help='Recipe to deploy') - parser_deploy.add_argument('target', help='Live target machine running an
ssh server: user@hostname[:destdir]') - parser_deploy.add_argument('-c',
'--no-host-check', help='Disable ssh host key checking',
action='store_true') - parser_deploy.add_argument('-s', '--show-status',
help='Show progress/status output', action='store_true') - parser_deploy.add_argument('-n', '--dry-run', help='List files to be
deployed only', action='store_true') + parser_deploy =
subparsers.add_parser(

scripts/lib/devtool/deploy.py +18 -1
+            'deploy-target',
+            help='Deploy recipe output files to live target machine')
+    parser_deploy.add_argument(
+            'recipename',
+            help='Recipe to deploy')
+    parser_deploy.add_argument(
+            'target',
+            help='Live target machine running an ssh server: '
+                 'user@hostname[:destdir]')
+    parser_deploy.add_argument(
+            '-c', '--no-host-check',
+            help='Disable ssh host key checking', action='store_true')
+    parser_deploy.add_argument(
+            '-s', '--show-status',
+            help='Show progress/status output', action='store_true')
+    parser_deploy.add_argument(
+            '-n', '--dry-run',
+            help='List files to be deployed only', action='store_true')
     parser_deploy.set_defaults(func=deploy)
 
-    parser_undeploy = subparsers.add_parser('undeploy-target',

help='Undeploy recipe output files in live target machine') - parser_undeploy.add_argument('recipename', help='Recipe to undeploy') - parser_undeploy.add_argument('target', help='Live target machine running an
ssh server: user@hostname') - parser_undeploy.add_argument('-c',
'--no-host-check', help='Disable ssh host key checking',
action='store_true') - parser_undeploy.add_argument('-s',
'--show-status', help='Show progress/status output', action='store_true') -
parser_undeploy.add_argument('-n', '--dry-run', help='List files to be
undeployed only', action='store_true') + parser_undeploy =
subparsers.add_parser(

scripts/lib/devtool/deploy.py +8 -0
+            'undeploy-target',
+            help='Undeploy recipe output files in live target machine')
+    parser_undeploy.add_argument(
+            'recipename',
+            help='Recipe to undeploy')
+    parser_undeploy.add_argument(
+            'target',
+            help='Live target machine running an ssh server:

user@hostname') + parser_undeploy.add_argument(

scripts/lib/devtool/deploy.py def undeploy(args, config, basepath, workspace): · line 188

Quoted 9 lines
scripts/lib/devtool/deploy.py +8 -0
+            '-c', '--no-host-check',
+            help='Disable ssh host key checking', action='store_true')
+    parser_undeploy.add_argument(
+            '-s', '--show-status',
+            help='Show progress/status output', action='store_true')
+    parser_undeploy.add_argument(
+            '-n', '--dry-run',
+            help='List files to be undeployed only', action='store_true')
     parser_undeploy.set_defaults(func=undeploy)

I have to be honest and say I don't find that all of these line wrapping changes improve readability. Maybe I am biased because I use a fairly large editing window - what's your editing setup?

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#13 lore raw

Re: [PATCH 11/11] devtool: deploy plugin: wrap long lines in code

Hi,

Quoted 190 lines · Paul Eggleton
Quoted 189 lines · On Monday 11 May 2015 16:17:11 Markus Lehtonen wrote:
---
 scripts/lib/devtool/deploy.py | 99

+++++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 27 deletions(-)

scripts/lib/devtool/deploy.py +0 -2
index 078c74b..f6ae433 100644
@@ -45,17 +45,23 @@ def deploy(args, config, basepath, workspace):
     deploy_dir = os.path.join(basepath, 'target_deploy', args.target)
     deploy_file = os.path.join(deploy_dir, args.recipename + '.list')
 
-    stdout, _ = exec_build_env_command(config.init_path, basepath, 'bitbake
-e %s' % args.recipename, shell=True) +    stdout, _ =

exec_build_env_command(config.init_path, basepath, +
'bitbake -e %s' % args.recipename, +
shell=True)
recipe_outdir = re.search(r'^D="(.*)"', stdout, re.MULTILINE).group(1) if not os.path.exists(recipe_outdir) or not os.listdir(recipe_outdir):
- logger.error('No files to deploy - have you built the %s recipe? If
so, the install step has not installed any files.' % args.recipename) +
logger.error('No files to deploy - have you built the %s recipe? If ' +
'so, the install step has not installed any files.' % + args.recipename)
return -1

if args.dry_run:
- print('Files to be deployed for %s on target %s:' %
(args.recipename, args.target)) + print('Files to be deployed for %s
on target %s:' %

scripts/lib/devtool/deploy.py +1 -1
+              (args.recipename, args.target))
         for root, _, files in os.walk(recipe_outdir):
             for fn in files:
-                print('  %s' % os.path.join(destdir, os.path.relpath(root,

recipe_outdir), fn)) + print(' %s' % os.path.join(
+ destdir, os.path.relpath(root, recipe_outdir), fn))
return 0

if os.path.exists(deploy_file):

scripts/lib/devtool/deploy.py +0 -1
@@ -65,12 +71,16 @@ def deploy(args, config, basepath, workspace):
 
     extraoptions = ''
     if args.no_host_check:
-        extraoptions += '-o UserKnownHostsFile=/dev/null -o

StrictHostKeyChecking=no' + extraoptions += '-o
UserKnownHostsFile=/dev/null'

scripts/lib/devtool/deploy.py +1 -1
+        extraoptions += ' -o StrictHostKeyChecking=no'
     if not args.show_status:
         extraoptions += ' -q'
-    ret = subprocess.call('scp -r %s %s/* %s:%s' % (extraoptions,

recipe_outdir, args.target, destdir), shell=True) + ret =
subprocess.call('scp -r %s %s/* %s:%s' %
+ (extraoptions, recipe_outdir, args.target,
destdir), + shell=True)

     if ret != 0:

- logger.error('Deploy failed - rerun with -s to get a complete error
message') + logger.error('Deploy failed - rerun with -s to get a
complete error ' + 'message')
return ret

logger.info('Successfully deployed %s' % recipe_outdir)

scripts/lib/devtool/deploy.py +0 -2
@@ -81,7 +91,8 @@ def deploy(args, config, basepath, workspace):
     files_list = []
     for root, _, files in os.walk(recipe_outdir):
         for filename in files:
-            filename = os.path.relpath(os.path.join(root, filename),
 recipe_outdir) +            filename = os.path.relpath(os.path.join(root,
 filename), +                                       recipe_outdir)
             files_list.append(os.path.join(destdir, filename))
 
     with open(deploy_file, 'w') as fobj:
@@ -91,13 +102,15 @@ def deploy(args, config, basepath, workspace):
 
 def undeploy(args, config, basepath, workspace):
     """Entry point for the devtool 'undeploy' subcommand"""
-    deploy_file = os.path.join(basepath, 'target_deploy', args.target,
 args.recipename + '.list') +    deploy_file = os.path.join(basepath,

'target_deploy', args.target, +
args.recipename + '.list')
if not os.path.exists(deploy_file):
logger.error('%s has not been deployed' % args.recipename) return -1

if args.dry_run:
- print('Previously deployed files to be un-deployed for %s on target
%s:' % (args.recipename, args.target)) + print('Previously deployed
files to be un-deployed for %s on target ' + '%s:' %
(args.recipename, args.target))
with open(deploy_file, 'r') as f:
for line in f:
print(' %s' % line.rstrip())

scripts/lib/devtool/deploy.py +0 -1
@@ -105,39 +118,71 @@ def undeploy(args, config, basepath, workspace):
 
     extraoptions = ''
     if args.no_host_check:
-        extraoptions += '-o UserKnownHostsFile=/dev/null -o

StrictHostKeyChecking=no' + extraoptions += '-o
UserKnownHostsFile=/dev/null '

scripts/lib/devtool/deploy.py +1 -1
+        extraoptions += ' -o StrictHostKeyChecking=no'
     if not args.show_status:
         extraoptions += ' -q'
 
-    ret = subprocess.call("scp %s %s %s:/tmp" % (extraoptions, deploy_file,

args.target), shell=True) + ret = subprocess.call("scp %s %s %s:/tmp" %
+ (extraoptions, deploy_file, args.target),
shell=True) if ret != 0:
- logger.error('Failed to copy file list to %s - rerun with -s to get
a complete error message' % args.target) + logger.error('Failed to
copy file list to %s - rerun with -s to get a ' +
'complete error message' % args.target)
return -1

- ret = subprocess.call("ssh %s %s 'xargs -n1 rm -f </tmp/%s'" %
(extraoptions, args.target, os.path.basename(deploy_file)), shell=True) +
ret = subprocess.call(

scripts/lib/devtool/deploy.py +3 -1
+            "ssh %s %s 'xargs -n1 rm -f </tmp/%s'" %
+            (extraoptions, args.target, os.path.basename(deploy_file)),
+            shell=True)
     if ret == 0:
         logger.info('Successfully undeployed %s' % args.recipename)
         os.remove(deploy_file)
     else:
-        logger.error('Undeploy failed - rerun with -s to get a complete

error message') + logger.error('Undeploy failed - rerun with -s to
get a complete error ' + 'message')

return ret

def register_commands(subparsers, context):
"""Register devtool subcommands from the deploy plugin"""
- parser_deploy = subparsers.add_parser('deploy-target', help='Deploy
recipe output files to live target machine') - parser_deploy.add_argument('recipename', help='Recipe to deploy') - parser_deploy.add_argument('target', help='Live target machine running an
ssh server: user@hostname[:destdir]') - parser_deploy.add_argument('-c',
'--no-host-check', help='Disable ssh host key checking',
action='store_true') - parser_deploy.add_argument('-s', '--show-status',
help='Show progress/status output', action='store_true') - parser_deploy.add_argument('-n', '--dry-run', help='List files to be
deployed only', action='store_true') + parser_deploy =
subparsers.add_parser(

scripts/lib/devtool/deploy.py +18 -1
+            'deploy-target',
+            help='Deploy recipe output files to live target machine')
+    parser_deploy.add_argument(
+            'recipename',
+            help='Recipe to deploy')
+    parser_deploy.add_argument(
+            'target',
+            help='Live target machine running an ssh server: '
+                 'user@hostname[:destdir]')
+    parser_deploy.add_argument(
+            '-c', '--no-host-check',
+            help='Disable ssh host key checking', action='store_true')
+    parser_deploy.add_argument(
+            '-s', '--show-status',
+            help='Show progress/status output', action='store_true')
+    parser_deploy.add_argument(
+            '-n', '--dry-run',
+            help='List files to be deployed only', action='store_true')
     parser_deploy.set_defaults(func=deploy)
 
-    parser_undeploy = subparsers.add_parser('undeploy-target',

help='Undeploy recipe output files in live target machine') - parser_undeploy.add_argument('recipename', help='Recipe to undeploy') - parser_undeploy.add_argument('target', help='Live target machine running an
ssh server: user@hostname') - parser_undeploy.add_argument('-c',
'--no-host-check', help='Disable ssh host key checking',
action='store_true') - parser_undeploy.add_argument('-s',
'--show-status', help='Show progress/status output', action='store_true') -
parser_undeploy.add_argument('-n', '--dry-run', help='List files to be
undeployed only', action='store_true') + parser_undeploy =
subparsers.add_parser(

scripts/lib/devtool/deploy.py +8 -0
+            'undeploy-target',
+            help='Undeploy recipe output files in live target machine')
+    parser_undeploy.add_argument(
+            'recipename',
+            help='Recipe to undeploy')
+    parser_undeploy.add_argument(
+            'target',
+            help='Live target machine running an ssh server:

user@hostname') + parser_undeploy.add_argument(

scripts/lib/devtool/deploy.py +5 -0
+            '-c', '--no-host-check',
+            help='Disable ssh host key checking', action='store_true')
+    parser_undeploy.add_argument(
+            '-s', '--show-status',
+            help='Show progress/status output', action='store_true')
Quoted 8 lines

scripts/lib/devtool/deploy.py def undeploy(args, config, basepath, workspace): · line 188

Quoted 4 lines
scripts/lib/devtool/deploy.py +3 -0
+    parser_undeploy.add_argument(
+            '-n', '--dry-run',
+            help='List files to be undeployed only', action='store_true')
     parser_undeploy.set_defaults(func=undeploy)

I have to be honest and say I don't find that all of these line wrapping changes improve readability. Maybe I am biased because I use a fairly large editing window - what's your editing setup?

On my laptop I usually have quite narrow windows (I guess around 100 or so). This also has to do with PEP8 (the Python style guide):
https://www.python.org/dev/peps/pep-0008/#id14

Thanks,
Markus