Compare commits

...

3 Commits

Author SHA1 Message Date
Ben McGinnes
b97ee3e0aa docs: python bindings howto
* Added a section on checking the version details of GPGME and the
  underlying engines.
* This is a component of the updated workaround in the previous
  commit(s).
2018-03-30 14:49:26 +11:00
Ben McGinnes
6a527a6407 script: groups work-around
* Updated script to match the methods in the HOWTO.
2018-03-30 14:12:42 +11:00
Ben McGinnes
de11f557a8 docs: python bindings howto
* Updated groups work around example to make sure it uses the correct
  version of gpgconf for the user invoking it (determined by the
  engine info).
2018-03-30 14:10:24 +11:00
2 changed files with 48 additions and 2 deletions

View File

@ -316,6 +316,46 @@
operation type has one. operation type has one.
** GPGME and Python Bindings Versions
:PROPERTIES:
:CUSTOM_ID: howto-get-version-info
:END:
Essentially there are two methods for checking useful version
information.
The first, =gpg.core.check_version=, returns the version of GPGME
installed. This should match the version of the Python bindings
themselves, but if the bindings have been installed separately from
GPGME (e.g. via PyPI, in spite of the current recommendations) then
a mismatch is possible and the effects may be unpredictable.
#+begin_src python
import gpg
print(gpg.core.check_version(version=None))
#+end_src
The quick way to see whether the output of =gpg.core.check_version()=
matches the GPGME library installed is to see if the version number
reported matches the first header produced by the =gpgme-tool=
installed with the library.
The second method, =gpg.core.get_engine_info=, returns version
information for the underlying engines, libraries and relevant
components. It also returns the full paths of certain important
executables, particularly =gpg= or =gpg.exe= for the OpenPGP engine
and =gpgsm= or =gpgsm.exe= for the S/MIME engine.
#+begin_src python
import gpg
for i in range(len(gpg.core.get_engine_info())):
print("{0}: version {1}".format(gpg.core.get_engine_info()[i].file_name,
gpg.core.get_engine_info()[i].version))
#+end_src
* Working with keys * Working with keys
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: howto-keys :CUSTOM_ID: howto-keys
@ -1334,9 +1374,12 @@
this information in Python. this information in Python.
#+begin_src python #+begin_src python
import gpg
import subprocess import subprocess
lines = subprocess.getoutput("gpgconf --list-options gpg").splitlines() gpgconf = gpg.core.get_engine_info()[2].file_name
gpgconf_cmd "{0} --list-options gpg".format(gpgconf)
lines = subprocess.getoutput(gpgconf_cmd).splitlines()
for i in range(len(lines)): for i in range(len(lines)):
if lines[i].startswith("group") is True: if lines[i].startswith("group") is True:

View File

@ -23,6 +23,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public along with this program; if not, see # Lesser General Public along with this program; if not, see
# <http://www.gnu.org/licenses/>. # <http://www.gnu.org/licenses/>.
import gpg
import subprocess import subprocess
""" """
@ -31,7 +32,9 @@ Intended for use with other scripts.
Usage: from groups import group_lists Usage: from groups import group_lists
""" """
lines = subprocess.getoutput("gpgconf --list-options gpg").splitlines() gpgconf = gpg.core.get_engine_info()[2].file_name
gpgconf_cmd "{0} --list-options gpg".format(gpgconf)
lines = subprocess.getoutput(gpgconf_cmd).splitlines()
for i in range(len(lines)): for i in range(len(lines)):
if lines[i].startswith("group") is True: if lines[i].startswith("group") is True: