Finding Return Code From GPG

Piet van Oostrum piet at cs.uu.nl
Fri Jul 7 18:26:06 EDT 2006


>>>>> Nomen Nescio <nobody at dizum.com> (NN) wrote:

>NN> Thanks, I used the popen function which did some of what I want. Here is
>NN> the code I used:

>NN> from subprocess import *

>NN> output = Popen(["gpg", "--output", "--verify", "sigtest"], stdout=PIPE).communicate()[0]

You need a filename argument for --output.

>NN> That worked, sort of - it did the verification at least and I can see
>NN> the return code. 

>NN> What is still not working is the display from gpg. It shows up on the
>NN> monitor screen like this:

>NN> gpg: Signature made Tue 04 Jul 2006 08:04:10 AM CET using DSA key ID
>NN> 06B09BA4
>NN> gpg: Good signature from "Boz Scraggs <scraggs at test.invalid>"

>NN> I need to get that into a file so I can parse it. Any further suggestions?

That output is passed to stderr. So you can get it in a string:

output = Popen(["gpg", "--output", "outfile", "--verify", "sigtest"], stderr=PIPE).communicate()[1]
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list