changeset cf94a93437e8 in /home/hg/repos/gajim
author: Yann Leboulanger asterix@lagaule.org branches: details:http://hg.gajim.org/gajim?cmd=changeset;node=cf94a93437e8 description: make GPG work with gpg2 binary if present. Fixes #8268
diffstat:
src/common/gajim.py | 17 ++++++++++++----- src/common/gpg.py | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-)
diffs (55 lines):
diff -r 11f067da78c6 -r cf94a93437e8 src/common/gajim.py --- a/src/common/gajim.py Sun Feb 21 14:04:31 2016 +0100 +++ b/src/common/gajim.py Sun Feb 21 18:54:31 2016 +0100 @@ -160,6 +160,7 @@ HAVE_PYCRYPTO = False
HAVE_GPG = True +GPG_BINARY = 'gpg' try: __import__('common.gnupg', globals(), locals(), [], 0) except ImportError: @@ -167,11 +168,17 @@ else: import os import subprocess - if os.name == 'nt': - gpg_cmd = 'gpg -h >nul 2>&1' - else: - gpg_cmd = 'gpg -h >/dev/null 2>&1' - if subprocess.call(gpg_cmd, shell=True): + def test_gpg(binary='gpg'): + if os.name == 'nt': + gpg_cmd = binary + ' -h >nul 2>&1' + else: + gpg_cmd = binary + ' -h >/dev/null 2>&1' + if subprocess.call(gpg_cmd, shell=True): + return False + return True + if test_gpg(binary='gpg2'): + GPG_BINARY = 'gpg2' + if not test_gpg(binary='gpg'): HAVE_GPG = False
HAVE_PYOPENSSL = True diff -r 11f067da78c6 -r cf94a93437e8 src/common/gpg.py --- a/src/common/gpg.py Sun Feb 21 14:04:31 2016 +0100 +++ b/src/common/gpg.py Sun Feb 21 18:54:31 2016 +0100 @@ -22,7 +22,7 @@ ## along with Gajim. If not, see http://www.gnu.org/licenses/. ##
-from common.gajim import HAVE_GPG +from common.gajim import HAVE_GPG, GPG_BINARY import os
if HAVE_GPG: @@ -30,7 +30,7 @@
class GnuPG(gnupg.GPG): def __init__(self, use_agent=False): - gnupg.GPG.__init__(self) + gnupg.GPG.__init__(self, gpgbinary=GPG_BINARY) self.encoding = 'utf-8' self.decode_errors = 'replace' self.passphrase = None