python examples: protonmail hkp scripts

* fixed a bug in the import try statement for both versions.
This commit is contained in:
Ben McGinnes 2018-11-06 14:11:01 +11:00
parent bded8ebc59
commit 1b9d30db08
2 changed files with 22 additions and 28 deletions

View File

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

View File

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