diff --git a/lang/python/examples/howto/export-secret-keys.py b/lang/python/examples/howto/export-secret-keys.py index f0a791ef..7203ded9 100755 --- a/lang/python/examples/howto/export-secret-keys.py +++ b/lang/python/examples/howto/export-secret-keys.py @@ -84,7 +84,13 @@ else: if os.path.exists(os.environ["GNUPGHOME"]) is True: hd = os.environ["GNUPGHOME"] else: - hd = subprocess.getoutput(gpgconfcmd) + try: + hd = subprocess.getoutput(gpgconfcmd) + except: + process = subprocess.Popen(gpgconfcmd.split(), + stdout=subprocess.PIPE) + procom = process.communicate() + hd = procom[0].decode().strip() gpgfile = "{0}/{1}.gpg".format(hd, keyfile) ascfile = "{0}/{1}.asc".format(hd, keyfile) diff --git a/lang/python/examples/howto/groups.py b/lang/python/examples/howto/groups.py index b8317b69..154961b1 100644 --- a/lang/python/examples/howto/groups.py +++ b/lang/python/examples/howto/groups.py @@ -37,7 +37,12 @@ if sys.platform == "win32": else: gpgconfcmd = "gpgconf --list-options gpg" -lines = subprocess.getoutput(gpgconfcmd).splitlines() +try: + lines = subprocess.getoutput(gpgconfcmd).splitlines() +except: + process = subprocess.Popen(gpgconfcmd.split(), stdout=subprocess.PIPE) + procom = process.communicate() + lines = procom[0].decode().splitlines() for i in range(len(lines)): if lines[i].startswith("group") is True: