Question about gnupg.GPG()

45 views
Skip to first unread message

Garrett Robinson

unread,
Sep 27, 2011, 7:28:20 PM9/27/11
to python-gnupg
Hello all! I have a question about the behavior of gnupg's init()
function, which I'm finding to be a bit strange.

When I run gnupg.GPG(), without the gnupghome parameter, it defaults
sensibly to the home directory of the current user, which is what I
want. However, if I don't want to rely on the default behavior and
instead wish to set it manually, I'm using a line like this:

gpg = gnupg.GPG(gnupghome=os.environ['HOME'])

which doesn't appear to work.

I'm testing them by then running gpg.list_keys().

gpg = gnupg.GPG()
gpg.list_keys()

returns the same list of keys as if I run $ gpg --list-keys in my
terminal

gpg = gnupg.GPG(gnupghome=os.environ['HOME'])
gpg.list_keys()

returns an empty list.

I know I can get the job done just using the default __init__, but
this behavior seems strange and inconsistent. I'd really appreciate it
if somebody could help me understand it!

For reference, I'm running Ubuntu 10.10, Python 2.6.6, and python-
gnupg 0.2.8.

Vinay Sajip

unread,
Sep 27, 2011, 8:37:37 PM9/27/11
to python-gnupg
On Sep 28, 12:28 am, Garrett Robinson <garrett.f.robin...@gmail.com>
wrote:

> When I run gnupg.GPG(), without the gnupghome parameter, it defaults
> sensibly to the home directory of the current user, which is what I
> want. However, if I don't want to rely on the default behavior and
> instead wish to set it manually, I'm using a line like this:
>
> gpg = gnupg.GPG(gnupghome=os.environ['HOME'])

I think that the default home directory for gnu is $HOME/.gnupg, not
$HOME. Try that and see if it works.

Regards,

Vinay Sajip
Reply all
Reply to author
Forward
0 new messages