make GPG work with gpg2 binary if present. Fixes #8268
This commit is contained in:
parent
3f89fafb44
commit
206746cbfb
|
@ -160,6 +160,7 @@ except ImportError:
|
||||||
HAVE_PYCRYPTO = False
|
HAVE_PYCRYPTO = False
|
||||||
|
|
||||||
HAVE_GPG = True
|
HAVE_GPG = True
|
||||||
|
GPG_BINARY = 'gpg'
|
||||||
try:
|
try:
|
||||||
__import__('common.gnupg', globals(), locals(), [], 0)
|
__import__('common.gnupg', globals(), locals(), [], 0)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -167,11 +168,17 @@ except ImportError:
|
||||||
else:
|
else:
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
def test_gpg(binary='gpg'):
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
gpg_cmd = 'gpg -h >nul 2>&1'
|
gpg_cmd = binary + ' -h >nul 2>&1'
|
||||||
else:
|
else:
|
||||||
gpg_cmd = 'gpg -h >/dev/null 2>&1'
|
gpg_cmd = binary + ' -h >/dev/null 2>&1'
|
||||||
if subprocess.call(gpg_cmd, shell=True):
|
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_GPG = False
|
||||||
|
|
||||||
HAVE_PYOPENSSL = True
|
HAVE_PYOPENSSL = True
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
## 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
|
import os
|
||||||
|
|
||||||
if HAVE_GPG:
|
if HAVE_GPG:
|
||||||
|
@ -30,7 +30,7 @@ if HAVE_GPG:
|
||||||
|
|
||||||
class GnuPG(gnupg.GPG):
|
class GnuPG(gnupg.GPG):
|
||||||
def __init__(self, use_agent=False):
|
def __init__(self, use_agent=False):
|
||||||
gnupg.GPG.__init__(self)
|
gnupg.GPG.__init__(self, gpgbinary=GPG_BINARY)
|
||||||
self.encoding = 'utf-8'
|
self.encoding = 'utf-8'
|
||||||
self.decode_errors = 'replace'
|
self.decode_errors = 'replace'
|
||||||
self.passphrase = None
|
self.passphrase = None
|
||||||
|
|
Loading…
Reference in New Issue