[git] GPGME - branch, master, updated. gpgme-1.12.0-103-gfe7e01d

by Ben McGinnes cvs at cvs.gnupg.org
Mon Dec 10 18:45:24 CET 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  fe7e01d164b64ad5e7f65cb80e4bf13f06d8d3ef (commit)
      from  7c63bfe4ab434b61a871aec4bc1d0a05b4c068e6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fe7e01d164b64ad5e7f65cb80e4bf13f06d8d3ef
Author: Ben McGinnes <ben at adversary.org>
Date:   Tue Dec 11 04:41:03 2018 +1100

    python: key import via HKP example
    
    * Fixed the logic used to search for any given pattern.
    * Added a sensible method of checking whether a pattern is a key ID or
      fingerprint.
    
    Tested-by: Ben McGinnes <ben at adversary.org>
    Signed-off-by: Ben McGinnes <ben at adversary.org>

diff --git a/lang/python/examples/howto/import-keys-hkp.py b/lang/python/examples/howto/import-keys-hkp.py
index e619524..832a888 100755
--- a/lang/python/examples/howto/import-keys-hkp.py
+++ b/lang/python/examples/howto/import-keys-hkp.py
@@ -35,6 +35,7 @@ This script imports one or more public keys from the SKS keyservers.
 c = gpg.Context()
 server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
 results = []
+keys = []
 
 if len(sys.argv) > 2:
     pattern = " ".join(sys.argv[1:])
@@ -43,23 +44,20 @@ elif len(sys.argv) == 2:
 else:
     pattern = input("Enter the pattern to search for keys or user IDs: ")
 
-try:
-    keys = server.search(pattern)
-    if keys is not None:
-        print("Found {0} key(s).".format(len(keys)))
-    else:
-        pass
-except Exception as e:
-    keys = []
+if pattern is not None:
+    try:
+        key = server.search(hex(int(pattern, 16)))
+    except ValueError as e:
+        key = server.search(pattern)
+    keys.append(key[0])
     for logrus in pattern.split():
-        if logrus.startswith("0x") is True:
+        try:
+            key = server.search(hex(int(logrus, 16)))
+        except ValueErrer as ve:
             key = server.search(logrus)
-        else:
-            key = server.search("0x{0}".format(logrus))
         keys.append(key[0])
-    print("Found {0} key(s).".format(len(keys)))
 
-if keys is not None:
+if len(keys) > 0:
     for key in keys:
         import_result = c.key_import(key.key_blob)
         results.append(import_result)

-----------------------------------------------------------------------

Summary of changes:
 lang/python/examples/howto/import-keys-hkp.py | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list