comparison src/bnpparibas.py @ 4:b4c2db70bbf2

Detect and report gpg invocations errors
author Daniele Nicolodi <daniele@grinta.net>
date Wed, 25 Mar 2015 01:38:07 +0100
parents 1311f6533978
children a47012c9db15
comparison
equal deleted inserted replaced
3:1311f6533978 4:b4c2db70bbf2
402 sender = parseaddr(sender)[1] 402 sender = parseaddr(sender)[1]
403 recipient = parseaddr(recipient)[1] 403 recipient = parseaddr(recipient)[1]
404 cmd = [ "gpg", "--homedir", self.homedir, "--batch", "--yes", "--no-options", "--armor", 404 cmd = [ "gpg", "--homedir", self.homedir, "--batch", "--yes", "--no-options", "--armor",
405 "--local-user", sender, "--recipient", recipient, "--sign", "--encrypt"] 405 "--local-user", sender, "--recipient", recipient, "--sign", "--encrypt"]
406 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 406 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
407 encdata = p.communicate(input=message.encode('utf-8'))[0].decode('ascii') 407 encdata, err = p.communicate(input=message.encode('utf-8'))[0].decode('ascii')
408 if p.returncode:
409 raise RuntimeError(p.returncode, err)
408 return encdata 410 return encdata
409 411
410 412
411 @click.command() 413 @click.command()
412 @click.argument('filename') 414 @click.argument('filename')