diff options
author | Ben McGinnes <[email protected]> | 2018-09-15 17:34:36 +0000 |
---|---|---|
committer | Ben McGinnes <[email protected]> | 2018-09-15 17:34:36 +0000 |
commit | 4e8a92ed14ea3da3d92f07d5f62fd325a2adebde (patch) | |
tree | 5cba12632c9115acb8de4cfe7b6e85ee3331904a | |
parent | Python examples: backwards compatibility (diff) | |
download | gpgme-4e8a92ed14ea3da3d92f07d5f62fd325a2adebde.tar.gz gpgme-4e8a92ed14ea3da3d92f07d5f62fd325a2adebde.zip |
Python bindings: examples
* lang/python/examples/howto/export-secret-keys.py and groups.py:
Updated the backwards compatibility adjustments to account for
unicode differences between python 2 and 3.
-rwxr-xr-x | lang/python/examples/howto/export-secret-keys.py | 5 | ||||
-rw-r--r-- | lang/python/examples/howto/groups.py | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lang/python/examples/howto/export-secret-keys.py b/lang/python/examples/howto/export-secret-keys.py index 7203ded9..0f4d8ee4 100755 --- a/lang/python/examples/howto/export-secret-keys.py +++ b/lang/python/examples/howto/export-secret-keys.py @@ -90,7 +90,10 @@ else: process = subprocess.Popen(gpgconfcmd.split(), stdout=subprocess.PIPE) procom = process.communicate() - hd = procom[0].decode().strip() + if sys.version_info[0] == 2: + hd = procom[0].strip() + else: + 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 154961b1..72135382 100644 --- a/lang/python/examples/howto/groups.py +++ b/lang/python/examples/howto/groups.py @@ -42,7 +42,10 @@ try: except: process = subprocess.Popen(gpgconfcmd.split(), stdout=subprocess.PIPE) procom = process.communicate() - lines = procom[0].decode().splitlines() + if sys.version_info[0] == 2: + lines = procom[0].splitlines() + else: + lines = procom[0].decode().splitlines() for i in range(len(lines)): if lines[i].startswith("group") is True: |