diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bpgpg.py | 22 |
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 |