Skip to content

Commit

Permalink
Fix ugly error when KeyNotFound in password group
Browse files Browse the repository at this point in the history
  • Loading branch information
cimnine committed Jan 20, 2021
1 parent 74726a0 commit b439433
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion development.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ git status

# Check Version
cat yktotp/tool.py | grep VERSION
cat setup.cfg | grep version

# Build egg locally
python3 setup.py sdist bdist_wheel
Expand All @@ -38,7 +39,7 @@ git tag x.y.z
git push --tags

# Update to next version
vim yktotp/tool.py
vim yktotp/tool.py setup.cfg
git commit -m "Prepare for next version" yktotp/tool.py
git push

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = yk-totp
# version = see setup.py
version = 0.1.6

description = A CLI tool to generate TOTP values from a password protected YubiKey by storing the password in the system-protected keyring.
# long_description = see setup.py
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from yktotp.tool import TOOL_VERSION
from setuptools import setup

with open('README.md', 'r', encoding='utf-8') as fh:
long_description = fh.read()

setup(
version=TOOL_VERSION,
long_description=long_description,
)
8 changes: 6 additions & 2 deletions yktotp/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from click import echo
from click.exceptions import Abort

from .error import WrongPasswordError
from .error import WrongPasswordError, KeyNotFound
from .tool import TOOL_NAME
from .lib import getDevice, getController, validate

Expand All @@ -19,7 +19,11 @@ def password_group(ctx, device_serial):
password repeatedly.
"""
ctx.ensure_object(dict)
ctx.obj['device'] = getDevice(device_serial)
try:
ctx.obj['device'] = getDevice(device_serial)
except KeyNotFound:
echo("The YubiKey '%s' is not connected right now." % device_serial)
exit(1)


@password_group.command()
Expand Down

0 comments on commit b439433

Please sign in to comment.