[git] GPGME - branch, pyme, updated. gpgme-1.5.4-13-g29887c9

by Ben McGinnes cvs at cvs.gnupg.org
Sat May 16 21:18:53 CEST 2015


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, pyme has been updated
       via  29887c9b28c0db14bf75e227a8082d23a2c151d2 (commit)
       via  c39cea7a07cec9ab34cd2026f47b6fba80fea3c8 (commit)
       via  0e6e6689ef1aea36c1cb3cb47e94f1f2ebbd97cb (commit)
       via  40290507bcdc63ab9023393d071167d455d70737 (commit)
       via  325b0ca341ae3ac8c3232f557ea2c381b4843969 (commit)
       via  ba3c9f2617955dc828309a4800e4f5b3f1c3a949 (commit)
       via  1c87ecb86ae364b18f69bca726021271fefaa1c1 (commit)
      from  24c738f5bb5c253a17962c62867d6c847250b41e (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 29887c9b28c0db14bf75e227a8082d23a2c151d2
Author: Ben McGinnes <ben at adversary.org>
Date:   Sun May 17 05:14:47 2015 +1000

    Explaining why not all scripts work
    
    * Some of them cannot be properly tested on OS X, especially with GTK in
      the mix (it works on OS X, but is unlikely to be as easily accessible
      as Cocoa or Qt).
    * Most major functions are showcased and do work, albeit sometimes with
      false positives of error messages, at least on OS X.

diff --git a/lang/py3-pyme/examples/Examples.rst b/lang/py3-pyme/examples/Examples.rst
new file mode 100644
index 0000000..18b03b2
--- /dev/null
+++ b/lang/py3-pyme/examples/Examples.rst
@@ -0,0 +1,7 @@
+===============
+Example Scripts
+===============
+
+Most of the examples have been converted to work with Python 3, just as the original versions worked with Python 2.  A small number produce errors on OS X, but may behave differently on other POSIX systems.  The GTK based scripts (PyGtkGpgKeys.py and pygpa.py) have not been modified at all.
+
+When using or referring to the example scripts here, the most common change has been the byte encoded strings, so if something does not work then chances are that it will be related to the encoding or decoding of UTF-8.

commit c39cea7a07cec9ab34cd2026f47b6fba80fea3c8
Author: Ben McGinnes <ben at adversary.org>
Date:   Sun May 17 05:07:12 2015 +1000

    Byte encoding
    
    * More string updates.
    * verifydetails.py still fails, but as Bernhard is still contactable, it
      might be worth him checking on it instead.

diff --git a/lang/py3-pyme/examples/sign.py b/lang/py3-pyme/examples/sign.py
index a0572fc..5667cc2 100755
--- a/lang/py3-pyme/examples/sign.py
+++ b/lang/py3-pyme/examples/sign.py
@@ -22,10 +22,10 @@ from pyme.constants.sig import mode
 
 core.check_version(None)
 
-plain = core.Data("Test message")
+plain = core.Data(b"Test message")
 sig = core.Data()
 c = core.Context()
-c.set_passphrase_cb(callbacks.passphrase_stdin, 'for signing')
+c.set_passphrase_cb(callbacks.passphrase_stdin, b'for signing')
 c.op_sign(plain, sig, mode.CLEAR)
 sig.seek(0,0)
 print(sig.read())
diff --git a/lang/py3-pyme/examples/signverify.py b/lang/py3-pyme/examples/signverify.py
index e2f8035..f8804ca 100755
--- a/lang/py3-pyme/examples/signverify.py
+++ b/lang/py3-pyme/examples/signverify.py
@@ -25,10 +25,10 @@ from pyme.constants.sig import mode
 
 core.check_version(None)
 
-plain = core.Data("Test message")
+plain = core.Data(b"Test message")
 sig = core.Data()
 c = core.Context()
-user = "joe at example.org"
+user = b"joe at example.org"
 
 c.signers_clear()
 # Add joe at example.org's keys in the list of signers
@@ -41,7 +41,7 @@ if not c.signers_enum(0):
 
 # This is a map between signer e-mail and its password
 passlist = {
-    "<joe at example.org>": "Crypt0R0cks"
+    b"<joe at example.org>": b"Crypt0R0cks"
     }
     
 # callback will return password based on the e-mail listed in the hint.
diff --git a/lang/py3-pyme/examples/t-edit.py b/lang/py3-pyme/examples/t-edit.py
index 24d36d3..6c53342 100644
--- a/lang/py3-pyme/examples/t-edit.py
+++ b/lang/py3-pyme/examples/t-edit.py
@@ -51,7 +51,7 @@ else:
     c = Context()
     c.set_passphrase_cb(lambda x,y,z: "abc")
     out = Data()
-    c.op_keylist_start("Alpha", 0)
+    c.op_keylist_start(b"Alpha", 0)
     key = c.op_keylist_next()
     c.op_edit(key, KeyEditor().edit_fnc, out, out)
     print("[-- Last response --]")
diff --git a/lang/py3-pyme/examples/verifydetails.py b/lang/py3-pyme/examples/verifydetails.py
index 8784487..0d47ba5 100755
--- a/lang/py3-pyme/examples/verifydetails.py
+++ b/lang/py3-pyme/examples/verifydetails.py
@@ -86,13 +86,13 @@ def main():
         sys.exit(1)
 
     if argc == 2:
-        print("trying to verify file: " + sys.argv[1])
-        verifyprintdetails(sys.argv[1])
+        print("trying to verify file: " + sys.argv[1].encode('utf-8'))
+        verifyprintdetails(sys.argv[1].encode('utf-8'))
     if argc == 3:
         print("trying to verify signature %s for file %s" \
-                    % (sys.argv[1], sys.argv[2]))
+                    % (sys.argv[1].encode('utf-8'), sys.argv[2].encode('utf-8')))
 
-        verifyprintdetails(sys.argv[1], sys.argv[2])
+        verifyprintdetails(sys.argv[1].encode('utf-8'), sys.argv[2].encode('utf-8'))
 
 if __name__ == "__main__":
     main()

commit 0e6e6689ef1aea36c1cb3cb47e94f1f2ebbd97cb
Author: Ben McGinnes <ben at adversary.org>
Date:   Sun May 17 04:57:26 2015 +1000

    No change, note added to explain why.

diff --git a/lang/py3-pyme/examples/testCMSgetkey.py b/lang/py3-pyme/examples/testCMSgetkey.py
index b0d3eb7..53fdef7 100644
--- a/lang/py3-pyme/examples/testCMSgetkey.py
+++ b/lang/py3-pyme/examples/testCMSgetkey.py
@@ -3,6 +3,10 @@
 # 20080124-2: removed some superflous imports
 # 20080703: adapted for pyme-0.8.0
 # This script is Free Software under GNU GPL v>=2.
+#
+# No modification made for python3 port, Bernhard can field this one
+# if it is still required.  -- Ben McGinnes
+#
 """A test applicaton for gpg_get_key() protocol.CMS.
 
 Tested on Debian Etch with

commit 40290507bcdc63ab9023393d071167d455d70737
Author: Ben McGinnes <ben at adversary.org>
Date:   Sun May 17 04:43:53 2015 +1000

    Strings vs. Bytes
    
    * CLI input must be byte encoded.

diff --git a/lang/py3-pyme/examples/inter-edit.py b/lang/py3-pyme/examples/inter-edit.py
index 088b292..f97232b 100644
--- a/lang/py3-pyme/examples/inter-edit.py
+++ b/lang/py3-pyme/examples/inter-edit.py
@@ -48,7 +48,7 @@ if len(sys.argv) != 2:
 else:
     c = Context()
     out = Data()
-    c.op_keylist_start(sys.argv[1], 0)
+    c.op_keylist_start(sys.argv[1].encode('utf-8'), 0)
     key = c.op_keylist_next()
     helper = {"skip": 0, "data": out}
     c.op_edit(key, edit_fnc, helper, out)

commit 325b0ca341ae3ac8c3232f557ea2c381b4843969
Author: Ben McGinnes <ben at adversary.org>
Date:   Sun May 17 04:22:53 2015 +1000

    More byte changes and passphrase changes
    
    * exportimport works, but will still segfault for an as yet unknown
      reason.
    * genkey produces a traceback error, but does create the key as
      intended.
    * matched passphrase in signverify.

diff --git a/lang/py3-pyme/examples/exportimport.py b/lang/py3-pyme/examples/exportimport.py
index 45f2f51..54204fb 100755
--- a/lang/py3-pyme/examples/exportimport.py
+++ b/lang/py3-pyme/examples/exportimport.py
@@ -27,7 +27,7 @@ core.check_version(None)
 expkey = core.Data()
 c = core.Context()
 c.set_armor(1)
-user = "joe at example.org"
+user = b"joe at example.org"
 
 print(" - Export %s's public keys - " % user)
 c.op_export(user, 0, expkey)
diff --git a/lang/py3-pyme/examples/genkey.py b/lang/py3-pyme/examples/genkey.py
index f2998cc..14497eb 100755
--- a/lang/py3-pyme/examples/genkey.py
+++ b/lang/py3-pyme/examples/genkey.py
@@ -36,7 +36,7 @@ Subkey-Length: 2048
 Name-Real: Joe Tester
 Name-Comment: with stupid passphrase
 Name-Email: joe at example.org
-Passphrase: Crypt0-R0cks
+Passphrase: Crypt0R0cks
 Expire-Date: 2020-12-31
 </GnupgKeyParms>
 """
diff --git a/lang/py3-pyme/examples/signverify.py b/lang/py3-pyme/examples/signverify.py
index 6c68838..e2f8035 100755
--- a/lang/py3-pyme/examples/signverify.py
+++ b/lang/py3-pyme/examples/signverify.py
@@ -41,7 +41,7 @@ if not c.signers_enum(0):
 
 # This is a map between signer e-mail and its password
 passlist = {
-    "<joe at example.org>": "Crypt0-R0cks"
+    "<joe at example.org>": "Crypt0R0cks"
     }
     
 # callback will return password based on the e-mail listed in the hint.

commit ba3c9f2617955dc828309a4800e4f5b3f1c3a949
Author: Ben McGinnes <ben at adversary.org>
Date:   Sun May 17 04:09:38 2015 +1000

    More bytes good
    
    * Another string to byte change.

diff --git a/lang/py3-pyme/examples/delkey.py b/lang/py3-pyme/examples/delkey.py
index 8bdb85b..dfcc5ea 100755
--- a/lang/py3-pyme/examples/delkey.py
+++ b/lang/py3-pyme/examples/delkey.py
@@ -29,6 +29,6 @@ core.check_version(None)
 
 c = core.Context()
 # 0 in keylist means to list not only public but secret keys as well.
-for thekey in [x for x in c.op_keylist_all("joe at example.org", 0)]:
+for thekey in [x for x in c.op_keylist_all(b"joe at example.org", 0)]:
     # 1 in delete means to delete not only public but secret keys as well.
     c.op_delete(thekey, 1)

commit 1c87ecb86ae364b18f69bca726021271fefaa1c1
Author: Ben McGinnes <ben at adversary.org>
Date:   Sun May 17 04:03:49 2015 +1000

    Updated encrypt-to-all
    
    * Changed plaintext string to byte literal.
    * Nested key selection in a try/except statement in case of
      UnicodeEncodeError instances.
    * Tested successfully on over 9,000 keys.

diff --git a/lang/py3-pyme/examples/encrypt-to-all.py b/lang/py3-pyme/examples/encrypt-to-all.py
index 087e6f7..8f9d250 100755
--- a/lang/py3-pyme/examples/encrypt-to-all.py
+++ b/lang/py3-pyme/examples/encrypt-to-all.py
@@ -18,9 +18,9 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 """
-This program will try to encrypt a simple message to each key on your keyring.
-If your keyring has any invalid keys on it, those keys will be removed
-and it will re-try the encryption."""
+This program will try to encrypt a simple message to each key on your
+keyring.  If your keyring has any invalid keys on it, those keys will
+be skipped and it will re-try the encryption."""
 
 from pyme import core
 from pyme.core import Data, Context
@@ -28,7 +28,7 @@ from pyme.constants import validity
 
 core.check_version(None)
 
-plain = Data('This is my message.')
+plain = Data(b'This is my message.')
 
 c = Context()
 c.set_armor(1)
@@ -41,16 +41,19 @@ def sendto(keylist):
 
 names = []
 for key in c.op_keylist_all(None, 0):
-    print(" *** Found key for %s" % key.uids[0].uid)
-    valid = 0
-    for subkey in key.subkeys:
-        keyid = subkey.keyid
-        if keyid == None:
-            break
-        can_encrypt = subkey.can_encrypt
-        valid += can_encrypt
-        print("     Subkey %s: encryption %s" % \
-              (keyid, can_encrypt and "enabled" or "disabled"))
+    try:
+        print(" *** Found key for %s" % key.uids[0].uid)
+        valid = 0
+        for subkey in key.subkeys:
+            keyid = subkey.keyid
+            if keyid == None:
+                break
+            can_encrypt = subkey.can_encrypt
+            valid += can_encrypt
+            print("     Subkey %s: encryption %s" % \
+                  (keyid, can_encrypt and "enabled" or "disabled"))
+    except UnicodeEncodeError as e:
+        print(e)
     
     if valid:
         names.append(key)

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

Summary of changes:
 lang/py3-pyme/examples/Examples.rst      |  7 +++++++
 lang/py3-pyme/examples/delkey.py         |  2 +-
 lang/py3-pyme/examples/encrypt-to-all.py | 31 +++++++++++++++++--------------
 lang/py3-pyme/examples/exportimport.py   |  2 +-
 lang/py3-pyme/examples/genkey.py         |  2 +-
 lang/py3-pyme/examples/inter-edit.py     |  2 +-
 lang/py3-pyme/examples/sign.py           |  4 ++--
 lang/py3-pyme/examples/signverify.py     |  6 +++---
 lang/py3-pyme/examples/t-edit.py         |  2 +-
 lang/py3-pyme/examples/testCMSgetkey.py  |  4 ++++
 lang/py3-pyme/examples/verifydetails.py  |  8 ++++----
 11 files changed, 42 insertions(+), 28 deletions(-)
 create mode 100644 lang/py3-pyme/examples/Examples.rst


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




More information about the Gnupg-commits mailing list