From faeef9c25ac7058476d2af3e563b5b6a703bfc03 Mon Sep 17 00:00:00 2001 From: Garrett Robinson Date: Sat, 7 Sep 2013 13:25:09 -0700 Subject: [PATCH] special case verbose=True to avoid passing invalid options to gpg --debug-level --- gnupg/_meta.py | 6 ++++++ gnupg/gnupg.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/gnupg/_meta.py b/gnupg/_meta.py index ee0e1f0..f032459 100644 --- a/gnupg/_meta.py +++ b/gnupg/_meta.py @@ -140,6 +140,12 @@ class GPGBase(object): log.error("GPGBase.__init__(): %s" % ae.message) raise RuntimeError(ae.message) else: + if verbose is True: + # The caller wants logging, but we need a valid --debug-level + # for gpg. Default to "basic", and warn about the ambiguity. + # (garrettr) + verbose = "basic" + log.warning('GPG(verbose=True) is ambiguous, defaulting to "basic" logging') self.verbose = verbose self.use_agent = use_agent diff --git a/gnupg/gnupg.py b/gnupg/gnupg.py index b23cecb..dd5bee8 100644 --- a/gnupg/gnupg.py +++ b/gnupg/gnupg.py @@ -76,6 +76,13 @@ class GPG(GPGBase): and private keyrings. Default is whatever GnuPG defaults to. + :param str,int,bool verbose: String or numeric value to pass to gpg's + ``--debug-level`` option. See the gpg man + page for the list of valid options. If + False, debug output is not generated by + the gpg binary. If True, defaults to + ``--debug-level basic.`` + :param str keyring: Name of keyring file containing public key data, if unspecified, defaults to 'pubring.gpg' in the ``homedir`` directory.