python examples: protonmail hkp scripts
authorBen McGinnes <ben@adversary.org>
Tue, 6 Nov 2018 03:11:01 +0000 (14:11 +1100)
committerBen McGinnes <ben@adversary.org>
Tue, 6 Nov 2018 03:11:01 +0000 (14:11 +1100)
* fixed a bug in the import try statement for both versions.

lang/python/examples/howto/pmkey-import-hkp-alt.py
lang/python/examples/howto/pmkey-import-hkp.py

index 673fe62..859de03 100755 (executable)
@@ -123,20 +123,17 @@ for keyterm in keyterms:
 
 for k in ksearch:
     print("Checking for key for: {0}".format(k))
-    try:
-        keys = server.search(k)
-        if isinstance(keys, list) is True:
-            for key in keys:
-                allkeys.append(key)
-                try:
-                    import_result = c.key_import(key.key_blob)
-                except Exception as e:
-                    import_result = c.key_import(key.key)
-        else:
-            paradox.append(keys)
-            import_result = None
-    except Exception as e:
-        import_result = None
+    import_result = None
+    keys = server.search(k)
+    if isinstance(keys, list) is True:
+        for key in keys:
+            allkeys.append(key)
+            try:
+                import_result = c.key_import(key.key_blob)
+            except Exception as e:
+                import_result = c.key_import(key.key)
+    else:
+        paradox.append(keys)
     results.append(import_result)
 
 for result in results:
index f7f6266..3b9345f 100755 (executable)
@@ -86,20 +86,17 @@ for keyterm in keyterms:
 
 for k in ksearch:
     print("Checking for key for: {0}".format(k))
-    try:
-        keys = server.search(k)
-        if isinstance(keys, list) is True:
-            for key in keys:
-                allkeys.append(key)
-                try:
-                    import_result = c.key_import(key.key_blob)
-                except Exception as e:
-                    import_result = c.key_import(key.key)
-        else:
-            paradox.append(keys)
-            import_result = None
-    except Exception as e:
-        import_result = None
+    import_result = None
+    keys = server.search(k)
+    if isinstance(keys, list) is True:
+        for key in keys:
+            allkeys.append(key)
+            try:
+                import_result = c.key_import(key.key_blob)
+            except Exception as e:
+                import_result = c.key_import(key.key)
+    else:
+        paradox.append(keys)
     results.append(import_result)
 
 for result in results: