summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>2013-10-21 11:08:30 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2013-10-21 21:50:38 +0200
commitdcd5524fc04730b0af05b28388d246cad97a91c2 (patch)
tree2b2aa1db4d25d5e8ae2db9aff21d053b279bafe0 /lib
parentf9fa9dac70b99a2cf12b494a9fe4440404a30c4e (diff)
lib/bpgpg.py: add simple gpg helper for gpg signing
Note that kup expects --armor --detach-sign, we'll pass that as part of our extra_args. The python gpg lib doesn't provide support for random arguments as this one, so just add our own little helper and carry it over. Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/bpgpg.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/bpgpg.py b/lib/bpgpg.py
new file mode 100644
index 00000000..3b5ec781
--- /dev/null
+++ b/lib/bpgpg.py
@@ -0,0 +1,22 @@
+import subprocess, os
+
+class GpgError(Exception):
+ pass
+class ExecutionError(GpgError):
+ def __init__(self, errcode):
+ self.error_code = errcode
+
+def sign(input_file, extra_args=[]):
+ cmd = ['gpg', '--sign']
+
+ cmd.extend(extra_args)
+ cmd.append(input_file)
+
+ process = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ close_fds=True, universal_newlines=True)
+ stdout = process.communicate()[0]
+ process.wait()
+ if process.returncode != 0:
+ raise ExecutionError(process.returncode)
+ return stdout