aboutsummaryrefslogtreecommitdiffstats
path: root/lang/py3-pyme/examples/testCMSgetkey.py
diff options
context:
space:
mode:
authorBen McGinnes <[email protected]>2015-05-05 17:09:44 +0000
committerBen McGinnes <[email protected]>2015-05-05 17:09:44 +0000
commitebd8734ad705afa4edc409787a00d4968d25e018 (patch)
tree9fa19302510c3cde9bf9f2c5385f786128af9b03 /lang/py3-pyme/examples/testCMSgetkey.py
parentPost release updates. (diff)
downloadgpgme-ebd8734ad705afa4edc409787a00d4968d25e018.tar.gz
gpgme-ebd8734ad705afa4edc409787a00d4968d25e018.zip
Python 3 port of PyME
* The entirety of the Python 3 port of PyME up to commit 2145348ec54c6027f2ea20f695de0277e2871405 * The old commit log has been saved as lang/py3-pyme/docs/old-commits.log * Can be viewed as a normal (separate) git repository at https://github.com/adversary-org/pyme3 * Utilising the submodule feature of git was deliberately skipped on humanitarian grounds (in order to prevent pain and suffering on the part of anyone having to manage this repository).
Diffstat (limited to '')
-rw-r--r--lang/py3-pyme/examples/testCMSgetkey.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/lang/py3-pyme/examples/testCMSgetkey.py b/lang/py3-pyme/examples/testCMSgetkey.py
new file mode 100644
index 00000000..b0d3eb75
--- /dev/null
+++ b/lang/py3-pyme/examples/testCMSgetkey.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+# initial 20080124 [email protected]
+# 20080124-2: removed some superflous imports
+# 20080703: adapted for pyme-0.8.0
+# This script is Free Software under GNU GPL v>=2.
+"""A test applicaton for gpg_get_key() protocol.CMS.
+
+Tested on Debian Etch with
+ pyme 0.8.0 (manually compiled)
+ libgpgme11 1.1.6-0kk2
+ gpgsm 2.0.9-0kk2
+"""
+
+import sys
+from pyme import core
+from pyme.constants import protocol
+
+def printgetkeyresults(keyfpr):
+ """Run gpgme_get_key()."""
+
+ # gpgme_check_version() necessary for initialisation according to
+ # gogme 1.1.6 and this is not done automatically in pyme-0.7.0
+ print("gpgme version:", core.check_version(None))
+ c = core.Context()
+ c.set_protocol(protocol.CMS)
+
+ key = c.get_key(keyfpr, False)
+
+ print("got key: ", key.subkeys[0].fpr)
+
+ for uid in key.uids:
+ print(uid.uid)
+
+def main():
+ if len(sys.argv) < 2:
+ print("fingerprint or unique key ID for gpgme_get_key()")
+ sys.exit(1)
+
+ printgetkeyresults(sys.argv[1])
+
+
+if __name__ == "__main__":
+ main()
+
+