[git] GPGME - branch, master, updated. gpgme-1.11.1-305-gb625258

by Ben McGinnes cvs at cvs.gnupg.org
Tue Sep 25 02:20:12 CEST 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  b625258d54782040195cc5ad3b255685af6f6c4e (commit)
       via  62e4e2cb5edb09183b9f9d448f992fe65cb6db85 (commit)
       via  e9da4d97107b40a48583775df34783f07be5dfdb (commit)
      from  b12b2cc99621fe32a2d698ce7f091f3225f35bd0 (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 b625258d54782040195cc5ad3b255685af6f6c4e
Author: Ben McGinnes <ben at adversary.org>
Date:   Tue Sep 25 10:17:39 2018 +1000

    docs: a typographical two-step
    
    * Sometimes you really do need or want punctuation in a heading, but
      ideally without something else generating whitespace and other
      annoyances to go with it.
    * Trying a real decimal point instead.
    
    Signed-off-by: Ben McGinnes <ben at adversary.org>

diff --git a/doc/gpgme-python-howto.texi b/doc/gpgme-python-howto.texi
index 69ae959..bc120d6 100644
--- a/doc/gpgme-python-howto.texi
+++ b/doc/gpgme-python-howto.texi
@@ -43,7 +43,7 @@ Introduction
 
 What's New
 
-* New in GPGME 1.12.0: New in GPGME 1120. 
+* New in GPGME 1·12·0::
 
 GPGME Concepts
 
@@ -235,11 +235,11 @@ all the other things which spurred the need for adding this section
 and its subsections.
 
 @menu
-* New in GPGME 1.12.0: New in GPGME 1120. 
+* New in GPGME 1·12·0::
 @end menu
 
- at node New in GPGME 1120
- at subsection New in GPGME 1.12.0
+ at node New in GPGME 1·12·0
+ at subsection New in GPGME 1·12·0
 
 There have been quite a number of additions to GPGME and the Python
 bindings to it since the last release of GPGME with versions 1.11.0
diff --git a/lang/python/docs/gpgme-python-howto.org b/lang/python/docs/gpgme-python-howto.org
index 90e133b..b54662c 100644
--- a/lang/python/docs/gpgme-python-howto.org
+++ b/lang/python/docs/gpgme-python-howto.org
@@ -82,7 +82,7 @@ section on other new things, but that's hardly important.  Not given
 all the other things which spurred the need for adding this section
 and its subsections.
 
-*** New in GPGME 1.12.0
+*** New in GPGME 1·12·0
     :PROPERTIES:
     :CUSTOM_ID: new-stuff-1-12-0
     :END:

commit 62e4e2cb5edb09183b9f9d448f992fe65cb6db85
Author: Ben McGinnes <ben at adversary.org>
Date:   Tue Sep 25 09:59:31 2018 +1000

    docs and examples: python bindings
    
    * Woumd up the "what's new" section.
    * Added an example for sending a key to the keyservers via hkp4py.
    * Updated the export key code to use a more complete check for the
      $GNUPGHOME location.
    * Expanded on the installation and reinstallation troubleshooting
      section.
    
    Tested-by: Ben McGinnes <ben at adversary.org>
    Signed-off-by: Ben McGinnes <ben at adversary.org>

diff --git a/doc/gpgme-python-howto.texi b/doc/gpgme-python-howto.texi
index 2e13d87..69ae959 100644
--- a/doc/gpgme-python-howto.texi
+++ b/doc/gpgme-python-howto.texi
@@ -64,6 +64,10 @@ GPGME Python bindings installation
 * Installation::
 * Known Issues::
 
+Requirements
+
+* Recommended Additions::
+
 Installation
 
 * Installing GPGME::
@@ -71,6 +75,7 @@ Installation
 Known Issues
 
 * Breaking Builds::
+* Reinstalling Responsibly::
 * Multiple installations::
 * Won't Work With Windows::
 * CFFI is the Best™ and GPGME should use it instead of SWIG::
@@ -101,6 +106,7 @@ Exporting keys
 
 * Exporting public keys::
 * Exporting secret keys::
+* Sending public keys to the SKS Keyservers::
 
 Basic Functions
 
@@ -445,7 +451,8 @@ The GPGME Python bindings only have three requirements:
 @enumerate
 @item
 A suitable version of Python 2 or Python 3.  With Python 2 that
-means Python 2.7 and with Python 3 that means Python 3.4 or higher.
+means CPython 2.7 and with Python 3 that means CPython 3.4 or
+higher.
 @item
 @uref{https://www.swig.org, SWIG}.
 @item
@@ -453,6 +460,33 @@ GPGME itself.  Which also means that all of GPGME's dependencies
 must be installed too.
 @end enumerate
 
+ at menu
+* Recommended Additions::
+ at end menu
+
+ at node Recommended Additions
+ at subsection Recommended Additions
+
+Though none of the following are absolute requirements, they are all
+recommended for use with the Python bindings.  In some cases these
+recommendations refer to which version(s) of CPython to use the
+bindings with, while others refer to third party modules which provide
+a significant advantage in some way.
+
+ at enumerate
+ at item
+If possible, use Python 3 instead of 2.
+ at item
+Favour a more recent version of Python since even 3.4 is due to
+reach EOL soon.  In production systems and services, Python 3.6
+should be robust enough to be relied on.
+ at item
+If possible add the following Python modules which are not part of
+the standard library: @uref{http://docs.python-requests.org/en/latest/index.html, Requests}, @uref{http://cython.org/, Cython} and @uref{https://github.com/Selfnet/hkp4py, hkp4py}.  Chances are
+quite high that at least the first one and maybe two of those will
+already be installed.
+ at end enumerate
+
 @node Installation
 @section Installation
 
@@ -495,6 +529,7 @@ they be encountered.
 
 @menu
 * Breaking Builds::
+* Reinstalling Responsibly::
 * Multiple installations::
 * Won't Work With Windows::
 * CFFI is the Best™ and GPGME should use it instead of SWIG::
@@ -559,10 +594,34 @@ If Python is set to precede one of the other languages then it is
 possible that the errors described here may interrupt the build
 process before generating bindings for those other languages.  In
 these cases it may be preferable to configure all preferred language
-howto-export-public-keybindings separately with alternative @samp{configure} steps for GPGME using
+bindings separately with alternative @samp{configure} steps for GPGME using
 the @samp{--enable-languages=$LANGUAGE} option.
 @end enumerate
 
+ at node Reinstalling Responsibly
+ at subsection Reinstalling Responsibly
+
+Regardless of whether you're installing for one version of Python or
+several, there will come a point where reinstallation is required.
+With most Python module installations, the installed files go into the
+relevant site-packages directory and are then forgotten about.  Then
+the module is upgraded, the new files are copied over the old and
+that's the end of the matter.
+
+While the same is true of these bindings, there have been intermittent
+issues observed on some platforms which have benefited significantly
+from removing all the previous installations of the bindings before
+installing the updated versions.
+
+Removing the previous version(s) is simply a matter of changing to the
+relevant @samp{site-packages} directory for the version of Python in
+question and removing the @samp{gpg/} directory and any accompanying
+egg-info files for that module.
+
+In most cases this will require root or administration privileges on
+the system, but the same is true of installing the module in the first
+place.
+
 @node Multiple installations
 @subsection Multiple installations
 
@@ -1427,6 +1486,7 @@ third is for exporting secret keys.
 @menu
 * Exporting public keys::
 * Exporting secret keys::
+* Sending public keys to the SKS Keyservers::
 @end menu
 
 @node Exporting public keys
@@ -1586,12 +1646,26 @@ else:
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
-if homedir.startswith("~"):
-    if os.path.exists(os.path.expanduser(homedir)) is True:
-        c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+    homedir = None
+elif homedir.startswith("~"):
+    userdir = os.path.expanduser(homedir)
+    if os.path.exists(userdir) is True:
+        homedir = os.path.realpath(userdir)
+    else:
+        homedir = None
+else:
+    homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+    homedir = None
+else:
+    if os.path.isdir(homedir) is False:
+        homedir = None
     else:
         pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
     c.home_dir = homedir
 else:
     pass
@@ -1656,12 +1730,26 @@ else:
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
-if homedir.startswith("~"):
-    if os.path.exists(os.path.expanduser(homedir)) is True:
-        c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+    homedir = None
+elif homedir.startswith("~"):
+    userdir = os.path.expanduser(homedir)
+    if os.path.exists(userdir) is True:
+        homedir = os.path.realpath(userdir)
+    else:
+        homedir = None
+else:
+    homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+    homedir = None
+else:
+    if os.path.isdir(homedir) is False:
+        homedir = None
     else:
         pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
     c.home_dir = homedir
 else:
     pass
@@ -1712,6 +1800,70 @@ else:
     pass
 @end example
 
+ at node Sending public keys to the SKS Keyservers
+ at subsection Sending public keys to the SKS Keyservers
+
+As with the previous section on importing keys, the @samp{hkp4py} module
+adds another option with exporting keys in order to send them to the
+public keyservers.
+
+The following example demonstrates how this may be done.
+
+ at example
+import gpg
+import hkp4py
+import os.path
+import sys
+
+print("""
+This script sends one or more public keys to the SKS keyservers and is
+essentially a slight variation on the export-key.py script.
+""")
+
+c = gpg.Context(armor=True)
+server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
+
+if len(sys.argv) > 2:
+    logrus = " ".join(sys.argv[1:])
+elif len(sys.argv) == 2:
+    logrus = sys.argv[1]
+else:
+    logrus = input("Enter the UID matching the key(s) to send: ")
+
+if len(logrus) > 0:
+    try:
+        export_result = c.key_export(pattern=logrus)
+    except Exception as e:
+        print(e)
+        export_result = None
+else:
+    export_result = c.key_export(pattern=None)
+
+if export_result is not None:
+    try:
+        try:
+            send_result = server.add(export_result)
+        except:
+            send_result = server.add(export_result.decode())
+        if send_result is not None:
+            print(send_result)
+        else:
+            pass
+    except Exception as e:
+        print(e)
+else:
+    pass
+ at end example
+
+An expanded version of this script with additional functions for
+specifying an alternative homedir location is in the examples
+directory as @samp{send-key-to-keyserver.py}.
+
+The @samp{hkp4py} module appears to handle both string and byte literal text
+data equally well, but the GPGME bindings deal primarily with byte
+literal data only and so this script sends in that format first, then
+tries the string literal form.
+
 @node Basic Functions
 @chapter Basic Functions
 
diff --git a/lang/python/docs/gpgme-python-howto.org b/lang/python/docs/gpgme-python-howto.org
index 6c599cb..90e133b 100644
--- a/lang/python/docs/gpgme-python-howto.org
+++ b/lang/python/docs/gpgme-python-howto.org
@@ -293,12 +293,34 @@ section for further details.
 The GPGME Python bindings only have three requirements:
 
 1. A suitable version of Python 2 or Python 3.  With Python 2 that
-   means Python 2.7 and with Python 3 that means Python 3.4 or higher.
+   means CPython 2.7 and with Python 3 that means CPython 3.4 or
+   higher.
 2. [[https://www.swig.org][SWIG]].
 3. GPGME itself.  Which also means that all of GPGME's dependencies
    must be installed too.
 
 
+*** Recommended Additions
+   :PROPERTIES:
+   :CUSTOM_ID: gpgme-python-recommendations
+   :END:
+
+Though none of the following are absolute requirements, they are all
+recommended for use with the Python bindings.  In some cases these
+recommendations refer to which version(s) of CPython to use the
+bindings with, while others refer to third party modules which provide
+a significant advantage in some way.
+
+1. If possible, use Python 3 instead of 2.
+2. Favour a more recent version of Python since even 3.4 is due to
+   reach EOL soon.  In production systems and services, Python 3.6
+   should be robust enough to be relied on.
+3. If possible add the following Python modules which are not part of
+   the standard library: [[http://docs.python-requests.org/en/latest/index.html][Requests]], [[http://cython.org/][Cython]] and [[https://github.com/Selfnet/hkp4py][hkp4py]].  Chances are
+   quite high that at least the first one and maybe two of those will
+   already be installed.
+
+
 ** Installation
    :PROPERTIES:
    :CUSTOM_ID: installation
@@ -398,10 +420,37 @@ If Python is set to precede one of the other languages then it is
 possible that the errors described here may interrupt the build
 process before generating bindings for those other languages.  In
 these cases it may be preferable to configure all preferred language
-howto-export-public-keybindings separately with alternative =configure= steps for GPGME using
+bindings separately with alternative =configure= steps for GPGME using
 the =--enable-languages=$LANGUAGE= option.
 
 
+*** Reinstalling Responsibly
+    :PROPERTIES:
+    :CUSTOM_ID: snafu-lessons-for-the-lazy
+    :END:
+
+Regardless of whether you're installing for one version of Python or
+several, there will come a point where reinstallation is required.
+With most Python module installations, the installed files go into the
+relevant site-packages directory and are then forgotten about.  Then
+the module is upgraded, the new files are copied over the old and
+that's the end of the matter.
+
+While the same is true of these bindings, there have been intermittent
+issues observed on some platforms which have benefited significantly
+from removing all the previous installations of the bindings before
+installing the updated versions.
+
+Removing the previous version(s) is simply a matter of changing to the
+relevant =site-packages= directory for the version of Python in
+question and removing the =gpg/= directory and any accompanying
+egg-info files for that module.
+
+In most cases this will require root or administration privileges on
+the system, but the same is true of installing the module in the first
+place.
+
+
 *** Multiple installations
     :PROPERTIES:
     :CUSTOM_ID: snafu-the-full-monty
@@ -1446,12 +1495,26 @@ else:
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
-if homedir.startswith("~"):
-    if os.path.exists(os.path.expanduser(homedir)) is True:
-        c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+    homedir = None
+elif homedir.startswith("~"):
+    userdir = os.path.expanduser(homedir)
+    if os.path.exists(userdir) is True:
+        homedir = os.path.realpath(userdir)
+    else:
+        homedir = None
+else:
+    homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+    homedir = None
+else:
+    if os.path.isdir(homedir) is False:
+        homedir = None
     else:
         pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
     c.home_dir = homedir
 else:
     pass
@@ -1516,12 +1579,26 @@ else:
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
-if homedir.startswith("~"):
-    if os.path.exists(os.path.expanduser(homedir)) is True:
-        c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+    homedir = None
+elif homedir.startswith("~"):
+    userdir = os.path.expanduser(homedir)
+    if os.path.exists(userdir) is True:
+        homedir = os.path.realpath(userdir)
+    else:
+        homedir = None
+else:
+    homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+    homedir = None
+else:
+    if os.path.isdir(homedir) is False:
+        homedir = None
     else:
         pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
     c.home_dir = homedir
 else:
     pass
@@ -1573,6 +1650,73 @@ else:
 #+END_SRC
 
 
+*** Sending public keys to the SKS Keyservers
+    :PROPERTIES:
+    :CUSTOM_ID: howto-send-public-key
+    :END:
+
+As with the previous section on importing keys, the =hkp4py= module
+adds another option with exporting keys in order to send them to the
+public keyservers.
+
+The following example demonstrates how this may be done.
+
+#+BEGIN_SRC python -i
+import gpg
+import hkp4py
+import os.path
+import sys
+
+print("""
+This script sends one or more public keys to the SKS keyservers and is
+essentially a slight variation on the export-key.py script.
+""")
+
+c = gpg.Context(armor=True)
+server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
+
+if len(sys.argv) > 2:
+    logrus = " ".join(sys.argv[1:])
+elif len(sys.argv) == 2:
+    logrus = sys.argv[1]
+else:
+    logrus = input("Enter the UID matching the key(s) to send: ")
+
+if len(logrus) > 0:
+    try:
+        export_result = c.key_export(pattern=logrus)
+    except Exception as e:
+        print(e)
+        export_result = None
+else:
+    export_result = c.key_export(pattern=None)
+
+if export_result is not None:
+    try:
+        try:
+            send_result = server.add(export_result)
+        except:
+            send_result = server.add(export_result.decode())
+        if send_result is not None:
+            print(send_result)
+        else:
+            pass
+    except Exception as e:
+        print(e)
+else:
+    pass
+#+END_SRC
+
+An expanded version of this script with additional functions for
+specifying an alternative homedir location is in the examples
+directory as =send-key-to-keyserver.py=.
+
+The =hkp4py= module appears to handle both string and byte literal text
+data equally well, but the GPGME bindings deal primarily with byte
+literal data only and so this script sends in that format first, then
+tries the string literal form.
+
+
 * Basic Functions
   :PROPERTIES:
   :CUSTOM_ID: howto-the-basics
diff --git a/lang/python/examples/howto/export-key.py b/lang/python/examples/howto/export-key.py
index 80768fe..c17f247 100755
--- a/lang/python/examples/howto/export-key.py
+++ b/lang/python/examples/howto/export-key.py
@@ -51,12 +51,26 @@ else:
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
-if homedir.startswith("~"):
-    if os.path.exists(os.path.expanduser(homedir)) is True:
-        c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+    homedir = None
+elif homedir.startswith("~"):
+    userdir = os.path.expanduser(homedir)
+    if os.path.exists(userdir) is True:
+        homedir = os.path.realpath(userdir)
+    else:
+        homedir = None
+else:
+    homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+    homedir = None
+else:
+    if os.path.isdir(homedir) is False:
+        homedir = None
     else:
         pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
     c.home_dir = homedir
 else:
     pass
diff --git a/lang/python/examples/howto/export-minimised-key.py b/lang/python/examples/howto/export-minimised-key.py
index 9d5f848..a5a453c 100755
--- a/lang/python/examples/howto/export-minimised-key.py
+++ b/lang/python/examples/howto/export-minimised-key.py
@@ -51,12 +51,26 @@ else:
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
-if homedir.startswith("~"):
-    if os.path.exists(os.path.expanduser(homedir)) is True:
-        c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+    homedir = None
+elif homedir.startswith("~"):
+    userdir = os.path.expanduser(homedir)
+    if os.path.exists(userdir) is True:
+        homedir = os.path.realpath(userdir)
+    else:
+        homedir = None
+else:
+    homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+    homedir = None
+else:
+    if os.path.isdir(homedir) is False:
+        homedir = None
     else:
         pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
     c.home_dir = homedir
 else:
     pass
diff --git a/lang/python/examples/howto/export-secret-key.py b/lang/python/examples/howto/export-secret-key.py
index ccc9f45..e7d4e3a 100755
--- a/lang/python/examples/howto/export-secret-key.py
+++ b/lang/python/examples/howto/export-secret-key.py
@@ -54,12 +54,26 @@ else:
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
-if homedir.startswith("~"):
-    if os.path.exists(os.path.expanduser(homedir)) is True:
-        c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+    homedir = None
+elif homedir.startswith("~"):
+    userdir = os.path.expanduser(homedir)
+    if os.path.exists(userdir) is True:
+        homedir = os.path.realpath(userdir)
+    else:
+        homedir = None
+else:
+    homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+    homedir = None
+else:
+    if os.path.isdir(homedir) is False:
+        homedir = None
     else:
         pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
     c.home_dir = homedir
 else:
     pass
diff --git a/lang/python/examples/howto/export-secret-keys.py b/lang/python/examples/howto/export-secret-keys.py
index f2f1ccd..f0fddc6 100755
--- a/lang/python/examples/howto/export-secret-keys.py
+++ b/lang/python/examples/howto/export-secret-keys.py
@@ -63,12 +63,26 @@ else:
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
-if homedir.startswith("~"):
-    if os.path.exists(os.path.expanduser(homedir)) is True:
-        c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+    homedir = None
+elif homedir.startswith("~"):
+    userdir = os.path.expanduser(homedir)
+    if os.path.exists(userdir) is True:
+        homedir = os.path.realpath(userdir)
+    else:
+        homedir = None
+else:
+    homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+    homedir = None
+else:
+    if os.path.isdir(homedir) is False:
+        homedir = None
     else:
         pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
     c.home_dir = homedir
 else:
     pass
diff --git a/lang/python/examples/howto/export-key.py b/lang/python/examples/howto/send-key-to-keyserver.py
similarity index 53%
copy from lang/python/examples/howto/export-key.py
copy to lang/python/examples/howto/send-key-to-keyserver.py
index 80768fe..3541b19 100755
--- a/lang/python/examples/howto/export-key.py
+++ b/lang/python/examples/howto/send-key-to-keyserver.py
@@ -4,6 +4,7 @@
 from __future__ import absolute_import, division, unicode_literals
 
 import gpg
+import hkp4py
 import os.path
 import sys
 
@@ -29,45 +30,69 @@ import sys
 # <http://www.gnu.org/licenses/>.
 
 print("""
-This script exports one or more public keys.
+This script sends one or more public keys to the SKS keyservers and is
+essentially a slight variation on the export-key.py script.
+
+The default is to send all keys if there is no pattern or search term.
 """)
 
 c = gpg.Context(armor=True)
+server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
 
-if len(sys.argv) >= 4:
-    keyfile = sys.argv[1]
-    logrus = sys.argv[2]
-    homedir = sys.argv[3]
-elif len(sys.argv) == 3:
-    keyfile = sys.argv[1]
-    logrus = sys.argv[2]
-    homedir = input("Enter the GPG configuration directory path (optional): ")
+if len(sys.argv) >= 3:
+    logrus = sys.argv[1]
+    homedir = sys.argv[2]
 elif len(sys.argv) == 2:
-    keyfile = sys.argv[1]
-    logrus = input("Enter the UID matching the key(s) to export: ")
+    logrus = sys.argv[1]
     homedir = input("Enter the GPG configuration directory path (optional): ")
 else:
-    keyfile = input("Enter the path and filename to save the key(s) to: ")
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
-if homedir.startswith("~"):
-    if os.path.exists(os.path.expanduser(homedir)) is True:
-        c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+    homedir = None
+elif homedir.startswith("~"):
+    userdir = os.path.expanduser(homedir)
+    if os.path.exists(userdir) is True:
+        homedir = os.path.realpath(userdir)
+    else:
+        homedir = None
+else:
+    homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+    homedir = None
+else:
+    if os.path.isdir(homedir) is False:
+        homedir = None
     else:
         pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
     c.home_dir = homedir
 else:
     pass
 
-try:
-    result = c.key_export(pattern=logrus)
-except:
-    result = c.key_export(pattern=None)
+if len(logrus) > 0:
+    try:
+        export_result = c.key_export(pattern=logrus)
+    except Exception as e:
+        print(e)
+        export_result = None
+else:
+    export_result = c.key_export(pattern=None)
 
-if result is not None:
-    with open(keyfile, "wb") as f:
-        f.write(result)
+if export_result is not None:
+    try:
+        try:
+            send_result = server.add(export_result)
+        except:
+            send_result = server.add(export_result.decode())
+        if send_result is not None:
+            print(send_result)
+        else:
+            pass
+    except Exception as e:
+        print(e)
 else:
     pass

commit e9da4d97107b40a48583775df34783f07be5dfdb
Author: Ben McGinnes <ben at adversary.org>
Date:   Tue Sep 25 04:32:13 2018 +1000

    docs: python bindings howto
    
    * Added a What's New section to summarise changes since the last
      release.  There have been quite a few and some attention does need
      to be drawn to some of them.
    * Confirming certain issues with some platform builds, especially
      BSD/OSX vs. Linux issues which will need to update the installation
      troubleshooting guides.

diff --git a/doc/gpgme-python-howto.texi b/doc/gpgme-python-howto.texi
index 2e30597..2e13d87 100644
--- a/doc/gpgme-python-howto.texi
+++ b/doc/gpgme-python-howto.texi
@@ -39,6 +39,11 @@ Introduction
 * Python 2 versus Python 3::
 * Examples::
 * Unofficial Drafts::
+* What's New::
+
+What's New
+
+* New in GPGME 1.12.0: New in GPGME 1120. 
 
 GPGME Concepts
 
@@ -175,6 +180,7 @@ Python bindings to programmatically leverage the GPGME library.
 * Python 2 versus Python 3::
 * Examples::
 * Unofficial Drafts::
+* What's New::
 @end menu
 
 @node Python 2 versus Python 3
@@ -214,6 +220,80 @@ on locations to read or download @ref{Draft Editions of this HOWTO, , draft edit
 at the end of it.  These are unofficial versions produced in between
 major releases.
 
+ at node What's New
+ at section What's New
+
+The most obviously new point for those reading this guide is this
+section on other new things, but that's hardly important.  Not given
+all the other things which spurred the need for adding this section
+and its subsections.
+
+ at menu
+* New in GPGME 1.12.0: New in GPGME 1120. 
+ at end menu
+
+ at node New in GPGME 1120
+ at subsection New in GPGME 1.12.0
+
+There have been quite a number of additions to GPGME and the Python
+bindings to it since the last release of GPGME with versions 1.11.0
+and 1.11.1 in April, 2018.
+
+The bullet points of new additiions are:
+
+ at itemize
+ at item
+an expanded section on @ref{Installation, , installing} and @ref{Known Issues, , troubleshooting} the Python
+bindings.
+ at item
+The release of Python 3.7.0; which appears to be working just fine
+with our bindings, in spite of intermittent reports of problems for
+many other Python projects with that new release.
+ at item
+In order to fix some other issues, there are certain underlying
+functions which are more exposed through the @ref{Context, , gpg.Context()}, but
+ongoing documentation ought to clarify that or otherwise provide the
+best means of using the bindings.  Some additions to @samp{gpg.core} and
+the @samp{Context()}, however, were intended (see below).
+ at item
+Continuing work in identifying and confirming the cause of
+oft-reported @ref{Won't Work With Windows, , problems installing the Python bindings on Windows}.
+ at item
+GSOC: Google's Surreptitiously Ordered Conscription @dots{} erm @dots{} oh,
+right; Google's Summer of Code.  Though there were two hopeful
+candidates this year; only one ended up involved with the GnuPG
+Project directly, the other concentrated on an unrelated third party
+project with closer ties to one of the GNU/Linux distributions than
+to the GnuPG Project.  Thus the Python bindings benefited from GSOC
+participant Jacob Adams, who added the key at math{_import} function; building
+on prior work by Tobias Mueller.
+ at item
+Several new methods functions were added to the gpg.Context(),
+including: @ref{Importing keys, , key at math{_import}}, @ref{Exporting keys, , key at math{_export}}, @ref{Exporting public keys, , key at math{_export}@math{_minimal}} and
+ at ref{Exporting secret keys, , key at math{_export}@math{_secret}}.
+ at item
+Importing and exporting examples include versions integrated with
+Marcel Fest's recently released @uref{https://github.com/Selfnet/hkp4py, HKP for Python} module.  Some
+ at ref{Keyserver access for Python, , additional notes on this module} are included at the end of the HOWTO.
+ at item
+Instructions for dealing with semi-walled garden implementations
+like ProtonMail are also included.  This is intended to make things
+a little easier when communicating with users of ProtonMail's
+services and should not be construed as an endorsement of said
+service.  The GnuPG Project neither favours, nor disfavours
+ProtonMail and the majority of this deals with interacting with the
+ProtonMail keyserver.
+ at item
+Semi-formalised the location where @ref{Draft Editions of this HOWTO, , draft versions} of this HOWTO may
+periodically be accessible.  This is both for the reference of
+others and testing the publishing of the document itself.
+ at item
+Added a new section for @ref{Advanced or Experimental Use Cases, , advanced or experimental use}.
+ at item
+Began the advanced use cases with @ref{C plus Python plus SWIG plus Cython, , a section} on using the module with
+ at uref{http://cython.org/, Cython}.
+ at end itemize
+
 @node GPGME Concepts
 @chapter GPGME Concepts
 
@@ -479,7 +559,7 @@ If Python is set to precede one of the other languages then it is
 possible that the errors described here may interrupt the build
 process before generating bindings for those other languages.  In
 these cases it may be preferable to configure all preferred language
-bindings separately with alternative @samp{configure} steps for GPGME using
+howto-export-public-keybindings separately with alternative @samp{configure} steps for GPGME using
 the @samp{--enable-languages=$LANGUAGE} option.
 @end enumerate
 
@@ -2673,7 +2753,11 @@ support for Python 2.7 as well and is available via PyPI.
 
 Since it rewrites the @samp{hkp} protocol prefix as @samp{http} and @samp{hkps} as
 @samp{https}, the module is able to be used even with servers which do not
-support the full scope of keyserver functions.  It also works quite
+support the full scope of keyserver functions. at footnote{Such as with ProtonMail servers.  This also means that
+restricted servers which only advertise either HTTP or HTTPS end
+points and not HKP or HKPS end points must still be identified as as
+HKP or HKPS within the Python Code.  The @samp{hkp4py} module will rewrite
+these appropriately when the connection is made to the server.}  It also works quite
 readily when incorporated into a @ref{C plus Python plus SWIG plus Cython, , Cython} generated and compiled version
 of any code.
 
diff --git a/lang/python/docs/gpgme-python-howto.org b/lang/python/docs/gpgme-python-howto.org
index 2f6ce73..6c599cb 100644
--- a/lang/python/docs/gpgme-python-howto.org
+++ b/lang/python/docs/gpgme-python-howto.org
@@ -72,6 +72,68 @@ at the end of it.  These are unofficial versions produced in between
 major releases.
 
 
+** What's New
+   :PROPERTIES:
+   :CUSTOM_ID: new-stuff
+   :END:
+
+The most obviously new point for those reading this guide is this
+section on other new things, but that's hardly important.  Not given
+all the other things which spurred the need for adding this section
+and its subsections.
+
+*** New in GPGME 1.12.0
+    :PROPERTIES:
+    :CUSTOM_ID: new-stuff-1-12-0
+    :END:
+
+There have been quite a number of additions to GPGME and the Python
+bindings to it since the last release of GPGME with versions 1.11.0
+and 1.11.1 in April, 2018.
+
+The bullet points of new additiions are:
+
+- an expanded section on [[#installation][installing]] and [[#snafu][troubleshooting]] the Python
+  bindings.
+- The release of Python 3.7.0; which appears to be working just fine
+  with our bindings, in spite of intermittent reports of problems for
+  many other Python projects with that new release.
+- In order to fix some other issues, there are certain underlying
+  functions which are more exposed through the [[#howto-get-context][gpg.Context()]], but
+  ongoing documentation ought to clarify that or otherwise provide the
+  best means of using the bindings.  Some additions to =gpg.core= and
+  the =Context()=, however, were intended (see below).
+- Continuing work in identifying and confirming the cause of
+  oft-reported [[#snafu-runtime-not-funtime][problems installing the Python bindings on Windows]].
+- GSOC: Google's Surreptitiously Ordered Conscription ... erm ... oh,
+  right; Google's Summer of Code.  Though there were two hopeful
+  candidates this year; only one ended up involved with the GnuPG
+  Project directly, the other concentrated on an unrelated third party
+  project with closer ties to one of the GNU/Linux distributions than
+  to the GnuPG Project.  Thus the Python bindings benefited from GSOC
+  participant Jacob Adams, who added the key_import function; building
+  on prior work by Tobias Mueller.
+- Several new methods functions were added to the gpg.Context(),
+  including: [[#howto-import-key][key_import]], [[#howto-export-key][key_export]], [[#howto-export-public-key][key_export_minimal]] and
+  [[#howto-export-secret-key][key_export_secret]].
+- Importing and exporting examples include versions integrated with
+  Marcel Fest's recently released [[https://github.com/Selfnet/hkp4py][HKP for Python]] module.  Some
+  [[#hkp4py][additional notes on this module]] are included at the end of the HOWTO.
+- Instructions for dealing with semi-walled garden implementations
+  like ProtonMail are also included.  This is intended to make things
+  a little easier when communicating with users of ProtonMail's
+  services and should not be construed as an endorsement of said
+  service.  The GnuPG Project neither favours, nor disfavours
+  ProtonMail and the majority of this deals with interacting with the
+  ProtonMail keyserver.
+- Semi-formalised the location where [[#draft-editions][draft versions]] of this HOWTO may
+  periodically be accessible.  This is both for the reference of
+  others and testing the publishing of the document itself.
+- Added a new section for [[#advanced-use][advanced or experimental use]].
+- Began the advanced use cases with [[#cython][a section]] on using the module with
+  [[http://cython.org/][Cython]].
+
+
 * GPGME Concepts
   :PROPERTIES:
   :CUSTOM_ID: gpgme-concepts
@@ -336,7 +398,7 @@ If Python is set to precede one of the other languages then it is
 possible that the errors described here may interrupt the build
 process before generating bindings for those other languages.  In
 these cases it may be preferable to configure all preferred language
-bindings separately with alternative =configure= steps for GPGME using
+howto-export-public-keybindings separately with alternative =configure= steps for GPGME using
 the =--enable-languages=$LANGUAGE= option.
 
 
@@ -2577,7 +2639,7 @@ support for Python 2.7 as well and is available via PyPI.
 
 Since it rewrites the =hkp= protocol prefix as =http= and =hkps= as
 =https=, the module is able to be used even with servers which do not
-support the full scope of keyserver functions.  It also works quite
+support the full scope of keyserver functions.[fn:6]  It also works quite
 readily when incorporated into a [[#cython][Cython]] generated and compiled version
 of any code.
 
@@ -2704,3 +2766,9 @@ POSIX systems which utilise single user mode (some even require it).
 keyservers for "gnupg.org" produces over 400 results, the majority of
 which aren't actually at the gnupg.org domain, but just included a
 comment regarding the project in their key somewhere.
+
+[fn:6] Such as with ProtonMail servers.  This also means that
+restricted servers which only advertise either HTTP or HTTPS end
+points and not HKP or HKPS end points must still be identified as as
+HKP or HKPS within the Python Code.  The =hkp4py= module will rewrite
+these appropriately when the connection is made to the server.

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

Summary of changes:
 doc/gpgme-python-howto.texi                        | 256 ++++++++++++++++++++-
 lang/python/docs/gpgme-python-howto.org            | 232 ++++++++++++++++++-
 lang/python/examples/howto/export-key.py           |  22 +-
 lang/python/examples/howto/export-minimised-key.py |  22 +-
 lang/python/examples/howto/export-secret-key.py    |  22 +-
 lang/python/examples/howto/export-secret-keys.py   |  22 +-
 .../{export-key.py => send-key-to-keyserver.py}    |  71 ++++--
 7 files changed, 588 insertions(+), 59 deletions(-)
 copy lang/python/examples/howto/{export-key.py => send-key-to-keyserver.py} (53%)


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




More information about the Gnupg-commits mailing list