Skip to content

Commit

Permalink
Fix a traceback when failed to unlock a keyring
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Apr 28, 2023
1 parent 0ea0015 commit 1a6fa63
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions osc/babysitter.py
Expand Up @@ -36,6 +36,14 @@ class RPMError(Exception):
pass


try:
from keyring.errors import KeyringLocked
except ImportError:

Check warning on line 41 in osc/babysitter.py

View check run for this annotation

Codecov / codecov/patch

osc/babysitter.py#L39-L41

Added lines #L39 - L41 were not covered by tests
# python-keyring is not installed
class KeyringLocked:
pass

Check warning on line 44 in osc/babysitter.py

View check run for this annotation

Codecov / codecov/patch

osc/babysitter.py#L43-L44

Added lines #L43 - L44 were not covered by tests


# the good things are stolen from Matt Mackall's mercurial


Expand Down Expand Up @@ -178,6 +186,8 @@ def run(prg, argv=None):
print(f'{e.fname}:', e.msg, file=sys.stderr)
except RPMError as e:
print(e, file=sys.stderr)
except KeyringLocked as e:

Check failure

Code scanning / CodeQL

Non-exception in 'except' clause Error

Non-exception
class 'KeyringLocked'
in exception handler which will never match raised exception.
print(e, file=sys.stderr)

Check warning on line 190 in osc/babysitter.py

View check run for this annotation

Codecov / codecov/patch

osc/babysitter.py#L189-L190

Added lines #L189 - L190 were not covered by tests
except CertVerificationError as e:
print(e, file=sys.stderr)
except urllib3.exceptions.MaxRetryError as e:
Expand Down

0 comments on commit 1a6fa63

Please sign in to comment.