[PATCH 1/2] pwclient: Unhardcode prints to ~/.pwclientrc

Daniel Axtens dja at axtens.net
Fri Aug 26 20:47:43 AEST 2016


Florian Fainelli <f.fainelli at gmail.com> writes:

> Even though the default location is ~/.pwclientrc, we can change it, so
> use CONFIG_FILE wherever we can to make the prints match the actual file
> location.
>
> Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>

Hi Florian,

I'm getting the following error with this patch applied.

----
Traceback (most recent call last):
  File "bin/pwclient", line 807, in <module>
    main()
  File "bin/pwclient", line 660, in main
    'No section for project %s in ' + CONFIG_FILE + '\n' % project_str)
TypeError: not all arguments converted during string formatting
----

I think the whole string needs to be bracketed, or make CONFIG_FILE
another string parameter?

Anyway, once I fix that, I get strings like this:

"No section for project xyzzy2 in /home/dja/.pwclientrc"

I'm not sure the full path is an improvement over "~/", but I'm not that
fussed either way, and I can see that your patch fixes a bug if you
change CONFIG_FILE.

Regards,
Daniel

> ---
>  patchwork/bin/pwclient | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/patchwork/bin/pwclient b/patchwork/bin/pwclient
> index a931dc904a39..531ad846b3b4 100755
> --- a/patchwork/bin/pwclient
> +++ b/patchwork/bin/pwclient
> @@ -616,7 +616,7 @@ def main():
>      config.read([CONFIG_FILE])
>  
>      if not config.has_section('options') and os.path.exists(CONFIG_FILE):
> -        sys.stderr.write('~/.pwclientrc is in the old format. Migrating it...')
> +        sys.stderr.write(CONFIG_FILE + ' is in the old format. Migrating it...')
>  
>          old_project = config.get('base', 'project')
>  
> @@ -642,7 +642,7 @@ def main():
>  
>          sys.stderr.write(' Done.\n')
>          sys.stderr.write(
> -            'Your old ~/.pwclientrc was saved to %s\n' % old_config_file)
> +            'Your old ' + CONFIG_FILE + ' was saved to %s\n' % old_config_file)
>          sys.stderr.write(
>              'and was converted to the new format. You may want to\n')
>          sys.stderr.write('inspect it before continuing.\n')
> @@ -653,15 +653,15 @@ def main():
>              project_str = config.get('options', 'default')
>          except:
>              action_parser.error(
> -                "No default project configured in ~/.pwclientrc")
> +                "No default project configured in " + CONFIG_FILE)
>  
>      if not config.has_section(project_str):
>          sys.stderr.write(
> -            'No section for project %s in ~/.pwclientrc\n' % project_str)
> +            'No section for project %s in ' + CONFIG_FILE + '\n' % project_str)
>          sys.exit(1)
>      if not config.has_option(project_str, 'url'):
>          sys.stderr.write(
> -            'No URL for project %s in ~/.pwclientrc\n' % project_str)
> +            'No URL for project %s in ' + CONFIG_FILE + '\n' % project_str)
>          sys.exit(1)
>      if not do_signoff and config.has_option('options', 'signoff'):
>          do_signoff = config.getboolean('options', 'signoff')
> -- 
> 2.7.4
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 859 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/patchwork/attachments/20160826/f4505c44/attachment.sig>


More information about the Patchwork mailing list