# HG changeset patch # User Paul Boddie # Date 1374435053 -7200 # Node ID 5435e7247634af069f5b87500b514732183bebb6 # Parent 30b92591d65b8508de7179712f019fa1d471ee31 Switched to using the communicate method for more reliable communication. diff -r 30b92591d65b -r 5435e7247634 MoinMessage.py --- a/MoinMessage.py Sat Jul 20 01:53:37 2013 +0200 +++ b/MoinMessage.py Sun Jul 21 21:30:53 2013 +0200 @@ -196,34 +196,17 @@ cmd = Popen(["gpg"] + self.conf_args + list(args), stdin=PIPE, stdout=PIPE, stderr=PIPE) - try: - # Attempt to write input to the command and to read output from the - # command. + # Attempt to write input to the command and to read output from the + # command. - try: - if text: - cmd.stdin.write(text) - cmd.stdin.close() - - text = cmd.stdout.read() - - # I/O errors can indicate the failure of the command. + text, self.errors = cmd.communicate(text) - except IOError: - pass - - self.errors = cmd.stderr.read() - - # Test for a zero result. + # Test for a zero result. - if not cmd.wait(): - return text - else: - raise MoinMessageError, self.errors - - finally: - cmd.stdout.close() - cmd.stderr.close() + if not cmd.returncode: + return text + else: + raise MoinMessageError, self.errors def verifyMessageText(self, signature, content):