Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions pwclient/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later

import configparser
import os
import sys

Expand Down Expand Up @@ -37,22 +38,33 @@ def main(argv=sys.argv[1:]):

action = args.subcmd

if not os.path.exists(CONFIG_FILE):
sys.stderr.write('Config file not found at %s.\n' % CONFIG_FILE)
sys.exit(1)

# grab settings from config files
config = utils.configparser.ConfigParser()
config = configparser.ConfigParser()
config.read([CONFIG_FILE])

if not config.has_section('options') and os.path.exists(CONFIG_FILE):
if config.has_section('base'):
utils.migrate_old_config_file(CONFIG_FILE, config)
sys.exit(1)

if not config.has_section('options'):
sys.stderr.write(
'No options section in %s. Did you forget to uncomment it?\n'
% CONFIG_FILE
)
sys.exit(1)

if 'project' in args and args.project:
project_str = args.project
else:
try:
project_str = config.get('options', 'default')
except (
utils.configparser.NoSectionError,
utils.configparser.NoOptionError,
configparser.NoSectionError,
configparser.NoOptionError,
):
sys.stderr.write(
'No default project configured in %s\n' % CONFIG_FILE
Expand Down
Loading
Loading