summaryrefslogtreecommitdiff
path: root/obnamlib/encryption.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-02-27 18:41:54 +0000
committerLars Wirzenius <liw@liw.fi>2014-02-27 18:41:54 +0000
commit67f10257a788662f1faac514d17f629ea84d1abe (patch)
tree42df3373c3abac6a81d398f3181b8abbfa6c48a9 /obnamlib/encryption.py
parent1fe493bfcfc943fa2f8a0b6912bea1dc12ed78d7 (diff)
downloadobnam-67f10257a788662f1faac514d17f629ea84d1abe.tar.gz
Get rid of obnamlib.Error
Diffstat (limited to 'obnamlib/encryption.py')
-rw-r--r--obnamlib/encryption.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/obnamlib/encryption.py b/obnamlib/encryption.py
index 1d7643bc..527c71af 100644
--- a/obnamlib/encryption.py
+++ b/obnamlib/encryption.py
@@ -23,6 +23,16 @@ import tracing
import obnamlib
+class EncryptionError(obnamlib.ObnamError):
+
+ pass
+
+
+class GpgError(EncryptionError):
+
+ msg = 'gpg failed with exit code {returncode}:\n{stderr}'
+
+
def generate_symmetric_key(numbits, filename='/dev/random'):
'''Generate a random key of at least numbits for symmetric encryption.'''
@@ -93,7 +103,7 @@ def _gpg_pipe(args, data, passphrase):
# Return output data, or deal with errors.
if p.returncode: # pragma: no cover
- raise obnamlib.EncryptionError(err)
+ raise GpgError(returncode=p.returncode, stderr=err)
return out
@@ -125,7 +135,7 @@ def _gpg(args, stdin='', gpghome=None):
# Return output data, or deal with errors.
if p.returncode: # pragma: no cover
- raise obnamlib.EncryptionError(err)
+ raise GpgError(returncode=p.returncode, stderr=err)
return out