Skip to content

Commit

Permalink
commandline: Handle missing config or credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Apr 11, 2023
1 parent 5f912a8 commit 713856d
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,33 @@ def post_parse_args(self, args):
# let's leave setting the right value to conf.get_config()
pass

conf.get_config(
override_apiurl=args.apiurl,
override_conffile=args.conffile,
override_debug=args.debug,
override_http_debug=args.http_debug,
override_http_full_debug=args.http_full_debug,
override_no_keyring=args.no_keyring,
override_post_mortem=args.post_mortem,
override_traceback=args.traceback,
override_verbose=args.verbose,
)
try:
conf.get_config(
override_apiurl=args.apiurl,
override_conffile=args.conffile,
override_debug=args.debug,
override_http_debug=args.http_debug,
override_http_full_debug=args.http_full_debug,
override_no_keyring=args.no_keyring,
override_post_mortem=args.post_mortem,
override_traceback=args.traceback,
override_verbose=args.verbose,
)
except oscerr.NoConfigfile as e:
print(e.msg, file=sys.stderr)
print(f"Creating osc configuration file {e.file} ...", file=sys.stderr)
conf.interactive_config_setup(e.file, args.apiurl)
print("done", file=sys.stderr)
self.post_parse_args(args)
except oscerr.ConfigMissingApiurl as e:
print(e.msg, file=sys.stderr)
conf.interactive_config_setup(e.file, e.url, initial=False)
self.post_parse_args(args)
except oscerr.ConfigMissingCredentialsError as e:
print(e.msg, file=sys.stderr)
print("Please enter new credentials.", file=sys.stderr)
conf.interactive_config_setup(e.file, e.url, initial=False)
self.post_parse_args(args)

# write config values back to args
# this is crucial mainly for apiurl to resolve an alias to full url
Expand Down

0 comments on commit 713856d

Please sign in to comment.