Skip to content

Commit 7032070

Browse files
vapierstephenfin
authored andcommitted
pwclient: handle missing ~/.pwclientrc better
The upgrade path will crash if ~/.pwclientrc doesn't exist, so add an explicit check for the file before we try to "upgrade" it. The default error messages don't mention the config file, so it can be a bit confusing what pwclient is complaining about when running. Signed-off-by: Mike Frysinger <[email protected]> Acked-by: Brian Norris <[email protected]> Reviewed-by: Stephen Finucane <[email protected]>
1 parent e13da7b commit 7032070

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

patchwork/bin/pwclient

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def main():
569569
config = ConfigParser.ConfigParser()
570570
config.read([CONFIG_FILE])
571571

572-
if not config.has_section('options'):
572+
if not config.has_section('options') and os.path.exists(CONFIG_FILE):
573573
sys.stderr.write('~/.pwclientrc is in the old format. Migrating it...')
574574

575575
old_project = config.get('base','project')
@@ -607,10 +607,10 @@ def main():
607607
sys.exit(1)
608608

609609
if not config.has_section(project_str):
610-
sys.stderr.write("No section for project %s\n" % project_str)
610+
sys.stderr.write('No section for project %s in ~/.pwclientrc\n' % project_str)
611611
sys.exit(1)
612612
if not config.has_option(project_str, 'url'):
613-
sys.stderr.write("No URL for project %s\n" % project_str)
613+
sys.stderr.write('No URL for project %s in ~/.pwclientrc\n' % project_str)
614614
sys.exit(1)
615615
if not do_signoff and config.has_option('options', 'signoff'):
616616
do_signoff = config.getboolean('options', 'signoff')

0 commit comments

Comments
 (0)