summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2015-09-25 01:37:51 -0400
committerLars Wirzenius <liw@liw.fi>2015-10-11 11:41:49 +0300
commit0555f7dac34270cf6b5d5684e1eb99415606f418 (patch)
tree9e57f4cc789e6a0e7993fc2059ad8b7df7603898
parentcd198b834f2002de65e89874aabe8c7c6942a0dc (diff)
downloadobnam-0555f7dac34270cf6b5d5684e1eb99415606f418.tar.gz
encryption: refactor _gpg_pipe to use _gpg
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
-rw-r--r--obnamlib/encryption.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/obnamlib/encryption.py b/obnamlib/encryption.py
index 7030359d..d76193ca 100644
--- a/obnamlib/encryption.py
+++ b/obnamlib/encryption.py
@@ -90,21 +90,14 @@ def _gpg_pipe(args, data, passphrase):
os.write(keypipe[1], passphrase + '\n')
os.close(keypipe[1])
- # Actually run gpg.
-
- argv = ['gpg', '--passphrase-fd', str(keypipe[0]), '-q', '--batch',
- '--no-textmode'] + args
- tracing.trace('argv=%s', repr(argv))
- p = subprocess.Popen(argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- out, err = p.communicate(data)
+ try:
+ out = _gpg(args + ['--passphrase-fd', str(keypipe[0])], stdin=data)
+ except: # pragma: no cover
+ os.close(keypipe[0])
+ raise
os.close(keypipe[0])
- # Return output data, or deal with errors.
- if p.returncode: # pragma: no cover
- raise GpgError(returncode=p.returncode, stderr=err)
-
return out