Current Path : /usr/share/doc/python-gnupginterface/ |
Current File : //usr/share/doc/python-gnupginterface/GnuPGInterface.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><title>Python: module GnuPGInterface</title> </head><body bgcolor="#f0f0f8"> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>GnuPGInterface</strong></big></big> (version 0.3.2)</font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/build/buildd/gnupginterface-0.3.2/GnuPGInterface.py">/build/buildd/gnupginterface-0.3.2/GnuPGInterface.py</a></font></td></tr></table> <p><tt>Interface to GNU Privacy Guard (<a href="#GnuPG">GnuPG</a>)<br> <br> <a href="#GnuPGInterface">GnuPGInterface</a> is a Python module to interface with <a href="#GnuPG">GnuPG</a>.<br> It concentrates on interacting with <a href="#GnuPG">GnuPG</a> via filehandles,<br> providing access to control <a href="#GnuPG">GnuPG</a> via versatile and extensible means.<br> <br> This module is based on <a href="#GnuPG">GnuPG</a>::Interface, a Perl module by the same author.<br> <br> Normally, using this module will involve creating a<br> <a href="#GnuPG">GnuPG</a> object, setting some options in it's 'options' data member<br> (which is of type <a href="#Options">Options</a>), creating some pipes<br> to talk with <a href="#GnuPG">GnuPG</a>, and then calling the run() method, which will<br> connect those pipes to the <a href="#GnuPG">GnuPG</a> process. run() returns a<br> <a href="#Process">Process</a> object, which contains the filehandles to talk to <a href="#GnuPG">GnuPG</a> with.<br> <br> Example code:<br> <br> >>> import <a href="#GnuPGInterface">GnuPGInterface</a><br> >>> <br> >>> plaintext = "Three blind mice"<br> >>> passphrase = "This is the passphrase"<br> >>> <br> >>> gnupg = <a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#GnuPG">GnuPG</a>()<br> >>> gnupg.options.armor = 1<br> >>> gnupg.options.meta_interactive = 0<br> >>> gnupg.options.extra_args.append('--no-secmem-warning')<br> >>> <br> >>> # Normally we might specify something in<br> >>> # gnupg.options.recipients, like<br> >>> # gnupg.options.recipients = [ '0xABCD1234', 'bob@foo.bar' ]<br> >>> # but since we're doing symmetric-only encryption, it's not needed.<br> >>> # If you are doing standard, public-key encryption, using<br> >>> # --encrypt, you will need to specify recipients before<br> >>> # calling gnupg.run()<br> >>> <br> >>> # First we'll encrypt the test_text input symmetrically<br> >>> p1 = gnupg.run(['--symmetric'],<br> ... create_fhs=['stdin', 'stdout', 'passphrase'])<br> >>> <br> >>> p1.handles['passphrase'].write(passphrase)<br> >>> p1.handles['passphrase'].close()<br> >>> <br> >>> p1.handles['stdin'].write(plaintext)<br> >>> p1.handles['stdin'].close()<br> >>> <br> >>> ciphertext = p1.handles['stdout'].read()<br> >>> p1.handles['stdout'].close()<br> >>> <br> >>> # process cleanup<br> >>> p1.wait()<br> >>> <br> >>> # Now we'll decrypt what we just encrypted it,<br> >>> # using the convience method to get the<br> >>> # passphrase to <a href="#GnuPG">GnuPG</a><br> >>> gnupg.passphrase = passphrase<br> >>> <br> >>> p2 = gnupg.run(['--decrypt'], create_fhs=['stdin', 'stdout'])<br> >>> <br> >>> p2.handles['stdin'].write(ciphertext)<br> >>> p2.handles['stdin'].close()<br> >>> <br> >>> decrypted_plaintext = p2.handles['stdout'].read()<br> >>> p2.handles['stdout'].close()<br> >>> <br> >>> # process cleanup<br> >>> p2.wait()<br> >>> <br> >>> # Our decrypted plaintext:<br> >>> decrypted_plaintext<br> 'Three blind mice'<br> >>><br> >>> # ...and see it's the same as what we orignally encrypted<br> >>> assert decrypted_plaintext == plaintext, "<a href="#GnuPG">GnuPG</a> decrypted output does not match original input"<br> >>><br> >>><br> >>> ##################################################<br> >>> # Now let's trying using run()'s attach_fhs paramter<br> >>> <br> >>> # we're assuming we're running on a unix...<br> >>> input = open('/etc/motd')<br> >>> <br> >>> p1 = gnupg.run(['--symmetric'], create_fhs=['stdout'],<br> ... attach_fhs={'stdin': input})<br> >>><br> >>> # <a href="#GnuPG">GnuPG</a> will read the stdin from /etc/motd<br> >>> ciphertext = p1.handles['stdout'].read()<br> >>><br> >>> # process cleanup<br> >>> p1.wait()<br> >>> <br> >>> # Now let's run the output through <a href="#GnuPG">GnuPG</a><br> >>> # We'll write the output to a temporary file,<br> >>> import tempfile<br> >>> temp = tempfile.TemporaryFile()<br> >>> <br> >>> p2 = gnupg.run(['--decrypt'], create_fhs=['stdin'],<br> ... attach_fhs={'stdout': temp})<br> >>> <br> >>> # give <a href="#GnuPG">GnuPG</a> our encrypted stuff from the first run<br> >>> p2.handles['stdin'].write(ciphertext)<br> >>> p2.handles['stdin'].close()<br> >>> <br> >>> # process cleanup<br> >>> p2.wait()<br> >>> <br> >>> # rewind the tempfile and see what <a href="#GnuPG">GnuPG</a> gave us<br> >>> temp.seek(0)<br> >>> decrypted_plaintext = temp.read()<br> >>> <br> >>> # compare what <a href="#GnuPG">GnuPG</a> decrypted with our original input<br> >>> input.seek(0)<br> >>> input_data = input.read()<br> >>><br> >>> assert decrypted_plaintext == input_data, "<a href="#GnuPG">GnuPG</a> decrypted output does not match original input"<br> <br> To do things like public-key encryption, simply pass do something<br> like:<br> <br> gnupg.passphrase = 'My passphrase'<br> gnupg.options.recipients = [ 'bob@foobar.com' ]<br> gnupg.run( ['--sign', '--encrypt'], create_fhs=..., attach_fhs=...)<br> <br> Here is an example of subclassing <a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#GnuPG">GnuPG</a>,<br> so that it has an encrypt_string() method that returns<br> ciphertext.<br> <br> >>> import <a href="#GnuPGInterface">GnuPGInterface</a><br> >>> <br> >>> class MyGnuPG(<a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#GnuPG">GnuPG</a>):<br> ...<br> ... def __init__(self):<br> ... <a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#GnuPG">GnuPG</a>.__init__(self)<br> ... setup_my_options()<br> ...<br> ... def setup_my_options(self):<br> ... self.<strong>options</strong>.armor = 1<br> ... self.<strong>options</strong>.meta_interactive = 0<br> ... self.<strong>options</strong>.extra_args.append('--no-secmem-warning')<br> ...<br> ... def encrypt_string(self, string, recipients):<br> ... gnupg.options.recipients = recipients # a list!<br> ... <br> ... proc = gnupg.run(['--encrypt'], create_fhs=['stdin', 'stdout'])<br> ... <br> ... proc.handles['stdin'].write(string)<br> ... proc.handles['stdin'].close()<br> ... <br> ... output = proc.handles['stdout'].read()<br> ... proc.handles['stdout'].close()<br> ...<br> ... proc.wait()<br> ... return output<br> ...<br> >>> gnupg = MyGnuPG()<br> >>> ciphertext = gnupg.encrypt_string("The secret", ['0x260C4FA3'])<br> >>><br> >>> # just a small sanity test here for doctest<br> >>> import types<br> >>> assert isinstance(ciphertext, types.StringType), "What <a href="#GnuPG">GnuPG</a> gave back is not a string!"<br> <br> Here is an example of generating a key:<br> >>> import <a href="#GnuPGInterface">GnuPGInterface</a><br> >>> gnupg = <a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#GnuPG">GnuPG</a>()<br> >>> gnupg.options.meta_interactive = 0<br> >>><br> >>> # We will be creative and use the logger filehandle to capture<br> >>> # what <a href="#GnuPG">GnuPG</a> says this time, instead stderr; no stdout to listen to,<br> >>> # but we capture logger to surpress the dry-run command.<br> >>> # We also have to capture stdout since otherwise doctest complains;<br> >>> # Normally you can let stdout through when generating a key.<br> >>> <br> >>> proc = gnupg.run(['--gen-key'], create_fhs=['stdin', 'stdout',<br> ... 'logger'])<br> >>> <br> >>> proc.handles['stdin'].write('''Key-Type: DSA<br> ... Key-Length: 1024<br> ... # We are only testing syntax this time, so dry-run<br> ... %dry-run<br> ... Subkey-Type: ELG-E<br> ... Subkey-Length: 1024<br> ... Name-Real: Joe Tester<br> ... Name-Comment: with stupid passphrase<br> ... Name-Email: joe@foo.bar<br> ... Expire-Date: 2y<br> ... Passphrase: abc<br> ... %pubring foo.pub<br> ... %secring foo.sec<br> ... ''')<br> >>> <br> >>> proc.handles['stdin'].close()<br> >>> <br> >>> report = proc.handles['logger'].read()<br> >>> proc.handles['logger'].close()<br> >>> <br> >>> proc.wait()<br> <br> <br> COPYRIGHT:<br> <br> Copyright (C) 2001 Frank J. Tobin, ftobin@neverending.org<br> <br> LICENSE:<br> <br> This library is free software; you can redistribute it and/or<br> modify it under the terms of the GNU Lesser General Public<br> License as published by the Free Software Foundation; either<br> version 2.1 of the License, or (at your option) any later version.<br> <br> This library is distributed in the hope that it will be useful,<br> but WITHOUT ANY WARRANTY; without even the implied warranty of<br> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br> Lesser General Public License for more details.<br> <br> You should have received a copy of the GNU Lesser General Public<br> License along with this library; if not, write to the Free Software<br> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br> or see <a href="http://www.gnu.org/copyleft/lesser.html">http://www.gnu.org/copyleft/lesser.html</a></tt></p> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#aa55cc"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="fcntl.html">fcntl</a><br> </td><td width="25%" valign=top><a href="os.html">os</a><br> </td><td width="25%" valign=top><a href="sys.html">sys</a><br> </td><td width="25%" valign=top></td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ee77aa"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> <td width="100%"><dl> <dt><font face="helvetica, arial"><a href="GnuPGInterface.html#GnuPG">GnuPG</a> </font></dt><dt><font face="helvetica, arial"><a href="GnuPGInterface.html#Options">Options</a> </font></dt><dt><font face="helvetica, arial"><a href="GnuPGInterface.html#Pipe">Pipe</a> </font></dt><dt><font face="helvetica, arial"><a href="GnuPGInterface.html#Process">Process</a> </font></dt></dl> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="GnuPG">class <strong>GnuPG</strong></a></font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>Class instances represent <a href="#GnuPG">GnuPG</a>.<br> <br> Instance attributes of a <a href="#GnuPG">GnuPG</a> object are:<br> <br> * call -- string to call <a href="#GnuPG">GnuPG</a> with. Defaults to "gpg"<br> <br> * passphrase -- Since it is a common operation<br> to pass in a passphrase to <a href="#GnuPG">GnuPG</a>,<br> and working with the passphrase filehandle mechanism directly<br> can be mundane, if set, the passphrase attribute<br> works in a special manner. If the passphrase attribute is set, <br> and no passphrase file object is sent in to <a href="#GnuPG-run">run</a>(),<br> then <a href="#GnuPG">GnuPG</a> instnace will take care of sending the passphrase to<br> <a href="#GnuPG">GnuPG</a>, the executable instead of having the user sent it in manually.<br> <br> * options -- Object of type <a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#Options">Options</a>. <br> Attribute-setting in options determines<br> the command-line options used when calling <a href="#GnuPG">GnuPG</a>.<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="GnuPG-__init__"><strong>__init__</strong></a>(self)</dt></dl> <dl><dt><a name="GnuPG-run"><strong>run</strong></a>(self, gnupg_commands, args<font color="#909090">=None</font>, create_fhs<font color="#909090">=None</font>, attach_fhs<font color="#909090">=None</font>)</dt><dd><tt>Calls <a href="#GnuPG">GnuPG</a> with the list of string commands gnupg_commands,<br> complete with prefixing dashes.<br> For example, gnupg_commands could be<br> '["--sign", "--encrypt"]'<br> Returns a <a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#Process">Process</a> object.<br> <br> args is an optional list of <a href="#GnuPG">GnuPG</a> command arguments (not options),<br> such as keyID's to export, filenames to process, etc.<br> <br> create_fhs is an optional list of <a href="#GnuPG">GnuPG</a> filehandle<br> names that will be set as keys of the returned <a href="#Process">Process</a> object's<br> 'handles' attribute. The generated filehandles can be used<br> to communicate with <a href="#GnuPG">GnuPG</a> via standard input, standard output,<br> the status-fd, passphrase-fd, etc.<br> <br> Valid <a href="#GnuPG">GnuPG</a> filehandle names are:<br> * stdin<br> * stdout<br> * stderr<br> * status<br> * passphase<br> * command<br> * logger<br> <br> The purpose of each filehandle is described in the <a href="#GnuPG">GnuPG</a><br> documentation.<br> <br> attach_fhs is an optional dictionary with <a href="#GnuPG">GnuPG</a> filehandle<br> names mapping to opened files. <a href="#GnuPG">GnuPG</a> will read or write<br> to the file accordingly. For example, if 'my_file' is an<br> opened file and 'attach_fhs[stdin] is my_file', then <a href="#GnuPG">GnuPG</a><br> will read its standard input from my_file. This is useful<br> if you want <a href="#GnuPG">GnuPG</a> to read/write to/from an existing file.<br> For instance:<br> <br> f = open("encrypted.gpg")<br> gnupg.<a href="#GnuPG-run">run</a>(["--decrypt"], attach_fhs={'stdin': f})<br> <br> Using attach_fhs also helps avoid system buffering<br> issues that can arise when using create_fhs, which<br> can cause the process to deadlock.<br> <br> If not mentioned in create_fhs or attach_fhs,<br> <a href="#GnuPG">GnuPG</a> filehandles which are a std* (stdin, stdout, stderr)<br> are defaulted to the running process' version of handle.<br> Otherwise, that type of handle is simply not used when calling <a href="#GnuPG">GnuPG</a>.<br> For example, if you do not care about getting data from <a href="#GnuPG">GnuPG</a>'s<br> status filehandle, simply do not specify it.<br> <br> <a href="#GnuPG-run">run</a>() returns a <a href="#Process">Process</a>() object which has a 'handles'<br> which is a dictionary mapping from the handle name<br> (such as 'stdin' or 'stdout') to the respective<br> newly-created FileObject connected to the running <a href="#GnuPG">GnuPG</a> process.<br> For instance, if the call was<br> <br> process = gnupg.<a href="#GnuPG-run">run</a>(["--decrypt"], stdin=1)<br> <br> after run returns 'process.handles["stdin"]'<br> is a FileObject connected to <a href="#GnuPG">GnuPG</a>'s standard input,<br> and can be written to.</tt></dd></dl> </td></tr></table> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><strong>GnuPGInterface</strong> = <a name="GnuPGInterface">class GnuPG</a></font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>Class instances represent <a href="#GnuPG">GnuPG</a>.<br> <br> Instance attributes of a <a href="#GnuPG">GnuPG</a> object are:<br> <br> * call -- string to call <a href="#GnuPG">GnuPG</a> with. Defaults to "gpg"<br> <br> * passphrase -- Since it is a common operation<br> to pass in a passphrase to <a href="#GnuPG">GnuPG</a>,<br> and working with the passphrase filehandle mechanism directly<br> can be mundane, if set, the passphrase attribute<br> works in a special manner. If the passphrase attribute is set, <br> and no passphrase file object is sent in to <a href="#GnuPGInterface-run">run</a>(),<br> then <a href="#GnuPG">GnuPG</a> instnace will take care of sending the passphrase to<br> <a href="#GnuPG">GnuPG</a>, the executable instead of having the user sent it in manually.<br> <br> * options -- Object of type <a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#Options">Options</a>. <br> Attribute-setting in options determines<br> the command-line options used when calling <a href="#GnuPG">GnuPG</a>.<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="GnuPG-__init__"><strong>__init__</strong></a>(self)</dt></dl> <dl><dt><a name="GnuPG-run"><strong>run</strong></a>(self, gnupg_commands, args<font color="#909090">=None</font>, create_fhs<font color="#909090">=None</font>, attach_fhs<font color="#909090">=None</font>)</dt><dd><tt>Calls <a href="#GnuPG">GnuPG</a> with the list of string commands gnupg_commands,<br> complete with prefixing dashes.<br> For example, gnupg_commands could be<br> '["--sign", "--encrypt"]'<br> Returns a <a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#Process">Process</a> object.<br> <br> args is an optional list of <a href="#GnuPG">GnuPG</a> command arguments (not options),<br> such as keyID's to export, filenames to process, etc.<br> <br> create_fhs is an optional list of <a href="#GnuPG">GnuPG</a> filehandle<br> names that will be set as keys of the returned <a href="#Process">Process</a> object's<br> 'handles' attribute. The generated filehandles can be used<br> to communicate with <a href="#GnuPG">GnuPG</a> via standard input, standard output,<br> the status-fd, passphrase-fd, etc.<br> <br> Valid <a href="#GnuPG">GnuPG</a> filehandle names are:<br> * stdin<br> * stdout<br> * stderr<br> * status<br> * passphase<br> * command<br> * logger<br> <br> The purpose of each filehandle is described in the <a href="#GnuPG">GnuPG</a><br> documentation.<br> <br> attach_fhs is an optional dictionary with <a href="#GnuPG">GnuPG</a> filehandle<br> names mapping to opened files. <a href="#GnuPG">GnuPG</a> will read or write<br> to the file accordingly. For example, if 'my_file' is an<br> opened file and 'attach_fhs[stdin] is my_file', then <a href="#GnuPG">GnuPG</a><br> will read its standard input from my_file. This is useful<br> if you want <a href="#GnuPG">GnuPG</a> to read/write to/from an existing file.<br> For instance:<br> <br> f = open("encrypted.gpg")<br> gnupg.<a href="#GnuPGInterface-run">run</a>(["--decrypt"], attach_fhs={'stdin': f})<br> <br> Using attach_fhs also helps avoid system buffering<br> issues that can arise when using create_fhs, which<br> can cause the process to deadlock.<br> <br> If not mentioned in create_fhs or attach_fhs,<br> <a href="#GnuPG">GnuPG</a> filehandles which are a std* (stdin, stdout, stderr)<br> are defaulted to the running process' version of handle.<br> Otherwise, that type of handle is simply not used when calling <a href="#GnuPG">GnuPG</a>.<br> For example, if you do not care about getting data from <a href="#GnuPG">GnuPG</a>'s<br> status filehandle, simply do not specify it.<br> <br> <a href="#GnuPGInterface-run">run</a>() returns a <a href="#Process">Process</a>() object which has a 'handles'<br> which is a dictionary mapping from the handle name<br> (such as 'stdin' or 'stdout') to the respective<br> newly-created FileObject connected to the running <a href="#GnuPG">GnuPG</a> process.<br> For instance, if the call was<br> <br> process = gnupg.<a href="#GnuPGInterface-run">run</a>(["--decrypt"], stdin=1)<br> <br> after run returns 'process.handles["stdin"]'<br> is a FileObject connected to <a href="#GnuPG">GnuPG</a>'s standard input,<br> and can be written to.</tt></dd></dl> </td></tr></table> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Options">class <strong>Options</strong></a></font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>Objects of this class encompass options passed to <a href="#GnuPG">GnuPG</a>.<br> This class is responsible for determining command-line arguments<br> which are based on options. It can be said that a <a href="#GnuPG">GnuPG</a><br> object has-a <a href="#Options">Options</a> object in its options attribute.<br> <br> Attributes which correlate directly to <a href="#GnuPG">GnuPG</a> options:<br> <br> Each option here defaults to false or None, and is described in<br> <a href="#GnuPG">GnuPG</a> documentation.<br> <br> Booleans (set these attributes to booleans)<br> <br> * armor<br> * no_greeting<br> * no_verbose<br> * quiet<br> * batch<br> * always_trust<br> * rfc1991<br> * openpgp<br> * force_v3_sigs<br> * no_options<br> * textmode<br> <br> Strings (set these attributes to strings)<br> <br> * homedir<br> * default_key<br> * comment<br> * compress_algo<br> * options<br> <br> Lists (set these attributes to lists)<br> <br> * recipients (***NOTE*** plural of 'recipient')<br> * encrypt_to<br> <br> Meta options<br> <br> Meta options are options provided by this module that do<br> not correlate directly to any <a href="#GnuPG">GnuPG</a> option by name,<br> but are rather bundle of options used to accomplish<br> a specific goal, such as obtaining compatibility with PGP 5.<br> The actual arguments each of these reflects may change with time. Each<br> defaults to false unless otherwise specified.<br> <br> meta_pgp_5_compatible -- If true, arguments are generated to try<br> to be compatible with PGP 5.x.<br> <br> meta_pgp_2_compatible -- If true, arguments are generated to try<br> to be compatible with PGP 2.x.<br> <br> meta_interactive -- If false, arguments are generated to try to<br> help the using program use <a href="#GnuPG">GnuPG</a> in a non-interactive<br> environment, such as CGI scripts. Default is true.<br> <br> extra_args -- Extra option arguments may be passed in<br> via the attribute extra_args, a list.<br> <br> >>> import <a href="#GnuPGInterface">GnuPGInterface</a><br> >>> <br> >>> gnupg = <a href="#GnuPGInterface">GnuPGInterface</a>.<a href="#GnuPG">GnuPG</a>()<br> >>> gnupg.options.armor = 1<br> >>> gnupg.options.recipients = ['Alice', 'Bob']<br> >>> gnupg.options.extra_args = ['--no-secmem-warning']<br> >>> <br> >>> # no need for users to call this normally; just for show here<br> >>> gnupg.options.<a href="#Options-get_args">get_args</a>()<br> ['--armor', '--recipient', 'Alice', '--recipient', 'Bob', '--no-secmem-warning']<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Options-__init__"><strong>__init__</strong></a>(self)</dt></dl> <dl><dt><a name="Options-get_args"><strong>get_args</strong></a>(self)</dt><dd><tt>Generate a list of <a href="#GnuPG">GnuPG</a> arguments based upon attributes.</tt></dd></dl> <dl><dt><a name="Options-get_meta_args"><strong>get_meta_args</strong></a>(self)</dt><dd><tt>Get a list of generated meta-arguments</tt></dd></dl> <dl><dt><a name="Options-get_standard_args"><strong>get_standard_args</strong></a>(self)</dt><dd><tt>Generate a list of standard, non-meta or extra arguments</tt></dd></dl> </td></tr></table> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Pipe">class <strong>Pipe</strong></a></font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>simple struct holding stuff about pipes we use<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Pipe-__init__"><strong>__init__</strong></a>(self, parent, child, direct)</dt></dl> </td></tr></table> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Process">class <strong>Process</strong></a></font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>Objects of this class encompass properties of a <a href="#GnuPG">GnuPG</a><br> process spawned by <a href="#GnuPG">GnuPG</a>.run().<br> <br> # gnupg is a <a href="#GnuPG">GnuPG</a> object<br> process = gnupg.run( [ '--decrypt' ], stdout = 1 )<br> out = process.handles['stdout'].read()<br> ...<br> os.waitpid( process.pid, 0 )<br> <br> Data Attributes<br> <br> handles -- This is a map of filehandle-names to<br> the file handles, if any, that were requested via run() and hence<br> are connected to the running <a href="#GnuPG">GnuPG</a> process. Valid names<br> of this map are only those handles that were requested.<br> <br> pid -- The PID of the spawned <a href="#GnuPG">GnuPG</a> process.<br> Useful to know, since once should call<br> os.waitpid() to clean up the process, especially<br> if multiple calls are made to run().<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Process-__init__"><strong>__init__</strong></a>(self)</dt></dl> <dl><dt><a name="Process-wait"><strong>wait</strong></a>(self)</dt><dd><tt>Wait on the process to exit, allowing for child cleanup.<br> Will raise an IOError if the process exits non-zero.</tt></dd></dl> </td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#55aa55"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> <td width="100%"><strong>__author__</strong> = 'Frank J. Tobin, ftobin@neverending.org'<br> <strong>__revision__</strong> = '$Id: GnuPGInterface.py,v 1.22 2002/01/11 20:22:04 ftobin Exp $'<br> <strong>__version__</strong> = '0.3.2'</td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#7799ee"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr> <tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td> <td width="100%">Frank J. Tobin, ftobin@neverending.org</td></tr></table> </body></html>