Commit 1922618f authored by Agate's avatar Agate 💬

Merge branch 'cryptfile__lazy_credentiel_exception_handling' into 'master'

Handling ValueError exception when commands executed

Closes #7

See merge request !6
parents 58ae4ea3 3026b208
Pipeline #4360 passed with stages
in 2 minutes and 56 seconds
......@@ -118,7 +118,12 @@ class lazy_credential():
def value(self):
if self._cached_value:
return self._cached_value
v = keyring.get_password(*self.args)
try:
v = keyring.get_password(*self.args)
except ValueError as e:
raise click.ClickException("Error while retrieving password from keyring: {}. Your password may be incorrect.".format(e.args[0]))
except Exception as e:
raise click.ClickException("Error while retrieving password from keyring: {}".format(e.args[0]))
self._cached_value = v
return v
......@@ -141,12 +146,7 @@ def set_server(ctx, url, token, use_auth=True):
parsed = urllib.parse.urlparse(url)
ctx.obj["SERVER_NETLOC"] = parsed.netloc
ctx.obj["SERVER_PROTOCOL"] = parsed.scheme
try:
token = (token or lazy_credential(url, "_")) if use_auth else None
except ValueError as e:
raise click.ClickException("Error while retrieving password from keyring: {}. Your password may be incorrect.".format(e.args[0]))
except Exception as e:
raise click.ClickException("Error while retrieving password from keyring: {}".format(e.args[0]))
token = (token or lazy_credential(url, "_")) if use_auth else None
ctx.obj["remote"] = api.get_api(
domain=ctx.obj["SERVER_NETLOC"],
protocol=ctx.obj["SERVER_PROTOCOL"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment