From b61ba51c0d1f7b7fc0f65d281fdf9d7b88857c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Sun, 19 Apr 2015 23:09:10 +0200 Subject: [PATCH] More user friendly error message when repository key file is not found Closes #236 --- CHANGES | 1 + attic/key.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 9ed6944c9..b0d2b749d 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ Version 0.16 ------------ (bugfix release, released on X) +- More user friendly error message when repository key file is not found (#236) - Fix parsing of iso 8601 timestamps with zero microseconds (#282) Version 0.15 diff --git a/attic/key.py b/attic/key.py index ef623f36c..42f8420af 100644 --- a/attic/key.py +++ b/attic/key.py @@ -17,6 +17,11 @@ class UnsupportedPayloadError(Error): """Unsupported payload type {}. A newer version is required to access this repository. """ +class KeyfileNotFoundError(Error): + """No key file for repository {} found in {}. + """ + + class HMAC(hmac.HMAC): """Workaround a bug in Python < 3.4 Where HMAC does not accept memoryviews """ @@ -221,7 +226,7 @@ class KeyfileKey(AESKeyBase): line = fd.readline().strip() if line and line.startswith(cls.FILE_ID) and line[10:] == id: return filename - raise Exception('Key file for repository with ID %s not found' % id) + raise KeyfileNotFoundError(repository._location.canonical_path(), get_keys_dir()) def load(self, filename, passphrase): with open(filename, 'r') as fd: