All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
To: Paul Eggleton <paul.eggleton@linux.intel.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 11/11] devtool: deploy plugin: wrap long lines in code
Date: Mon, 18 May 2015 16:05:39 +0300	[thread overview]
Message-ID: <1431954339.9508.30.camel@linux.intel.com> (raw)
In-Reply-To: <4904789.A7T5g0hHDe@peggleto-mobl.ger.corp.intel.com>

Hi,

On Tue, 2015-05-12 at 16:20 +0100, Paul Eggleton wrote:
> On Monday 11 May 2015 16:17:11 Markus Lehtonen wrote:
> > Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
> > ---
> >  scripts/lib/devtool/deploy.py | 99
> > +++++++++++++++++++++++++++++++------------ 1 file changed, 72
> > insertions(+), 27 deletions(-)
> > 
> > diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py
> > index 078c74b..f6ae433 100644
> > --- a/scripts/lib/devtool/deploy.py
> > +++ b/scripts/lib/devtool/deploy.py
> > @@ -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)
> 
> 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



      reply	other threads:[~2015-05-18 13:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11 13:17 [PATCH 00/11] devtool: code style fixes Markus Lehtonen
2015-05-11 13:17 ` [PATCH 01/11] devtool: standard plugins: add missing docstrings Markus Lehtonen
2015-05-11 13:17 ` [PATCH 02/11] devtool: standard plugins: remove unused import Markus Lehtonen
2015-05-11 13:17 ` [PATCH 03/11] devtool: standard plugins: rename usunused variable Markus Lehtonen
2015-05-11 13:17 ` [PATCH 04/11] devtool: lib: add missing docstrings Markus Lehtonen
2015-05-11 13:17 ` [PATCH 05/11] devtool: lib: remove unnecessary re-import Markus Lehtonen
2015-05-11 13:17 ` [PATCH 06/11] devtool: lib: wrap long lines in code Markus Lehtonen
2015-05-11 13:17 ` [PATCH 07/11] devtool: deploy plugin: fix bad indentation Markus Lehtonen
2015-05-11 13:17 ` [PATCH 08/11] devtool: deploy plugin: add missing docstrings Markus Lehtonen
2015-05-11 13:17 ` [PATCH 09/11] devtool: deploy plugin: remove unnecessary re-import Markus Lehtonen
2015-05-11 13:17 ` [PATCH 10/11] devtool: deploy plugin: rename unused variables Markus Lehtonen
2015-05-11 13:17 ` [PATCH 11/11] devtool: deploy plugin: wrap long lines in code Markus Lehtonen
2015-05-12 15:20   ` Paul Eggleton
2015-05-18 13:05     ` Markus Lehtonen [this message]

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=1431954339.9508.30.camel@linux.intel.com \
    --to=markus.lehtonen@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=paul.eggleton@linux.intel.com \
    /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.