Commit Graph

485 Commits

Author SHA1 Message Date
Ben McGinnes
b30ebf8972 doc: python bindings examples
* Explicitly stated that all this code is released under the GPLv2+
  and the LGPLv2.1+.
2018-03-20 08:39:49 +11:00
Ben McGinnes
8f7672ad1b doc: python bindings example README
* Added the same license as used with the HOWTO.
* Since these examples are so basic, they'll be dual licensed the same
  as GPGME itself (otherwise it would slip too dangerously against the
  need for permissive licensing of crypto libraries).
2018-03-20 08:31:53 +11:00
Ben McGinnes
6950a63e63 docs: python bindings examples
* Added reference to location where all the examples included in the
  HOWTO will be available as executable scripts.
* Included a short README file in that location.
2018-03-20 08:26:57 +11:00
Ben McGinnes
3e0f68fdff example: python bindings encryption
* Since we don't want to encourage accessing the low level functions
  (e.g. op_encrypt), but since this example can still be useful to
  understand, renaming it and will add new encryption examples to
  match the instructions in the HOWTO.
2018-03-20 08:07:22 +11:00
Ben McGinnes
d5f6dec048 doc: python bindings howto
* Slight python-gnupg clarification.  See also this thread:
  https://lists.gnupg.org/pipermail/gnupg-devel/2018-March/033528.html
2018-03-19 15:03:00 +11:00
Ben McGinnes
0fb8a5d45c doc: python bindings howto
* Adjusted the python-gnupg so the comments regarding insecure
  invocation of commands via subprocess (shell=True) were a major
  historical issue and not a a current issue.
* Not including Vinay Sajip's requested change to say it is now secure
  since no audit of the current code base has been performed and my
  last major inspection of that code was around the time I first
  ported PyME to Python 3 in 2015.
2018-03-19 13:09:46 +11:00
Ben McGinnes
bf67cf433f doc: python bindings todo list
* Checked off several points of howto coverage as completed.
* Reorganised to move S/MIME coverage to its own separate group of tasks.
* Noted only revocation remains for howto completion.
2018-03-19 12:46:41 +11:00
Ben McGinnes
1779d7b9d6 doc: python bindings howto
* deconstructing multi-recipient encryption.
2018-03-19 10:39:53 +11:00
Ben McGinnes
64c5886132 doc: python bindings howto
* Replaced the single encryption methods with one main way (i.e. cut
  the low level stuff involving SEEK_SET instructions).
2018-03-19 10:00:44 +11:00
Ben McGinnes
4811ff7b6c doc: python bindings howto
* moved single encrytion examples up to the first ones, pending merge
  and major cut.
* This is basically just to make future checks of revisions a little easier.
2018-03-19 08:49:17 +11:00
Ben McGinnes
82c5af225f doc: python bindings howto
* Stripped decryption example to the bare bones as suggested by Justus.
2018-03-19 08:43:36 +11:00
Ben McGinnes
b549f69d05 doc: python bindings howto
* Made the changes suggested by Jakub Wilk on gnupg-devel.
* Still need to make the far more comprehensive changes suggested by Justus.
2018-03-17 03:46:02 +11:00
Ben McGinnes
431897a4c4 doc: python bindings howto
* Added clarification on why it's not on PyPI.
2018-03-16 03:52:58 +11:00
Ben McGinnes
22e2445bee doc: python bindings howto
* fixed custom_id for decryption so the XHTML validates.
2018-03-16 01:48:56 +11:00
Ben McGinnes
94a95ac123 doc: python bindings howto
* Promoted final encryption example so that it will appear as heading
  6.1.3 when exported to HTML or PDF.
2018-03-16 01:34:22 +11:00
Ben McGinnes
3d0c7a2202 doc: python bindings howto
* Fixed a minor typographic error.
* Bumped version number in preparation for merge with master.
* While there are probably a few more things worthy of being added
  (mainly how to revoke things), this document is essentially ready
  for publication now.

Signed-off-by: Ben McGinnes <ben@adversary.org>
2018-03-15 16:13:34 +11:00
Ben McGinnes
961aea212e doc: python bindings howto
* Added key signing.
2018-03-15 15:51:01 +11:00
Ben McGinnes
7ac65b1083 doc: python bindings howto
* Added a new user ID for Danger Mouse.
* Removed the empty entry for key preferences since that is handled
  through gpg.conf and/or editing the key directly.
2018-03-15 15:16:23 +11:00
Ben McGinnes
9e3e4a835c doc: python bindings howto
* Spell checking and fixing the few errors.
2018-03-15 14:59:36 +11:00
Ben McGinnes
b02d9d0a7b doc: python bindings howto
* Added an encryption subkey to Danger Mouse's primary key.
2018-03-15 14:43:44 +11:00
Ben McGinnes
5432e5f9d1 doc: python bindings howto
* generated a new primary key for Danger Mouse in an alternative homedir.
2018-03-15 14:01:30 +11:00
Ben McGinnes
5d1dd2abe5 doc: python bindings howto
* Added sections for key generation and key editing.
2018-03-15 12:27:45 +11:00
Ben McGinnes
1d05e6aa4e doc: python bindings howto
* Added c.get_key instructions and examples.
2018-03-15 12:14:29 +11:00
Ben McGinnes
b35aaef7a3 doc: python bindings howto
* Added text for verifying signatures.
2018-03-15 11:18:02 +11:00
Ben McGinnes
6bc12a0eeb doc: python bindings howto
* Added 4 signature verification methods and partial text for them.
2018-03-15 07:20:31 +11:00
Ben McGinnes
e5c85fba25 doc: python bindings howto
* Added description for detached signatures.
2018-03-15 04:07:57 +11:00
Ben McGinnes
ada059b071 doc: python bindings howto
* Fixed multiple sample code examples of writing output to a file.
* Added the description of detached signatures.
2018-03-15 03:51:51 +11:00
Ben McGinnes
ef27f3781a doc: python bindings todo
* minor phrasing fix.
2018-03-14 20:40:50 +11:00
Ben McGinnes
423fdcd465 doc: python bindings howto
* Added recommended method of single encryption with description.
2018-03-14 20:36:30 +11:00
Ben McGinnes
a71205dc3b doc: python binding howto
* Clarified which English dialects this is written in.
* Translating to American can happen *after* it's done.
** The Yank version would probably want to change some of the examples
   anyway.
* Began the description for normal/default signing.
2018-03-14 02:40:41 +11:00
Ben McGinnes
a10dcb4f13 doc: python bindings howto
* Added a section on key selection.
* Included recommendation for using fingerprint when selecting one
  specific key.
* Also included the most ironically amusing example of multiple key
  selection in a GPG guide.  Hey, it's public data ... (heh).
2018-03-14 02:21:44 +11:00
Ben McGinnes
952b6042f7 doc: python bindings howto
* Added explanation of the ascendance of Python 3 over Python 2 in the
  guide to the intro.
* Expanded key selection description so people know what not to
  include regarding key IDs with this key selection method.
2018-03-14 01:41:21 +11:00
Ben McGinnes
c92da2c7eb doc: python bindings howto
* Added key selection for specifying signing key or keys.
2018-03-13 19:20:44 +11:00
Ben McGinnes
e489ddd08a doc: python bindings howto
* During the course of working out the updated signature methods,
  determined that key selection (including counting) will beed to be
  presented before the basic functions.
* Moved "working with keys" up.
2018-03-13 18:32:30 +11:00
Ben McGinnes
f29bda8d71 doc: python bindings howto
* Signatures have changed as a result of the recent update from Justus.
* Sample code updated.
* Text to follow later.
2018-03-13 15:03:11 +11:00
Ben McGinnes
c27a7a3f99 doc: python bindings howto
* Added text description for the decryption example.
2018-03-13 11:50:38 +11:00
Ben McGinnes
f81adeba99 doc: python bindings howto
* Added a miscellaneous work-arounds section at the end.
* Included code in said miscellaneous section for accessing the groups
  specified in a gpg.conf file.
* It's a bit ugly since it does require subprocess (but not call,
  Popen or shell access and only accesses one command).
2018-03-13 08:26:22 +11:00
Ben McGinnes
36dfbdffea doc: python bindings howto
* Fixed a spelling error in the key counting text.
2018-03-13 07:49:42 +11:00
Ben McGinnes
484e9a6229 doc: python bindings howto
* updated multi-encryption final example to be complete.
* second example shows most likely method of reading plaintext.
* updated example filenames to stick with running gag
  (i.e. secret_plans.txt).
2018-03-13 07:42:04 +11:00
Ben McGinnes
a8f48b6f57 doc: python bindings howto
* error corrections.
* multiple typesetting fixes only required due to certain archaic
  eccentricities of LaTeX.
* a couple of minor python PEP8 compliance corrections.
2018-03-13 06:09:53 +11:00
Ben McGinnes
83b1336cee doc: python bindings howto
* Fixed an error in the encryption try/except statement.
2018-03-13 05:42:50 +11:00
Ben McGinnes
0e1300ce77 doc: python bindings howto
* Added a more complicated encryption example with a few variations on
  the encryption method to account for untrusted recipient keys,
  signing or not signing, including or excluding default keys and so
  on.
2018-03-13 04:55:44 +11:00
Ben McGinnes
7ebc5a3570 doc: python bindings howto
* Switched from links to some external docs to using footnotes where
  necessary.
* Ideally the howto should be as stand alone as possible.
* Also it makes it difficult to convert to another format for
  proof-reading if there are links that the conversion can't find.
2018-03-13 00:33:11 +11:00
Ben McGinnes
172baaf4d3 doc: python bindings HOWTO
* Added instructions and code to count the number of public and secret
  keys available since it was quick and easy.
2018-03-09 20:45:14 +11:00
Ben McGinnes
f2c1e8d8d5 doc: python TODO list
* Slightly tweaked one heading to make it clear it wasn't a duplicate.
2018-03-09 20:44:02 +11:00
Ben McGinnes
0168646394 doc: python bindings howto
* Wrote the text description explaining each step in the most basic
  encryption operation.
* Will need to include additional examples for encrypting to multiple
  recipients using Context().encrypt instead of Context().op_encrypt.
2018-03-09 16:49:05 +11:00
Ben McGinnes
93252df9dc doc: python bindings TODO list
* Updated to reflect the most recent work on the HOWTO for the Python
  bindings.
2018-03-09 15:27:40 +11:00
Ben McGinnes
ab81c2d868 doc: python bindings howto
* Added example for verifying both detached and "in-line" signatures.
2018-03-09 15:22:24 +11:00
Ben McGinnes
fa4927146b docs: python bindings howto update.
* Added all four signing code examples that are most likely to be
  used: armoured, clearsigned, detached armoured and detached binary.
* May remove some examples and just discuss the differences, but it
  depends on the way the text is filled out.
2018-03-09 07:53:57 +11:00
Ben McGinnes
c767a4a359 doc: python bindings howto update
* Added example of decryption.
* included some quick notes for myself regarding aspects to explain
  when I flesh out the explanatory text.
2018-03-09 05:25:49 +11:00
Ben McGinnes
75463d5895 doc: Basic operation of the python bindings
* Added sample code for encrypting some text to a single key.
* Basically I'm just lifting existing production code and changing the
  key IDs from mine to "0x12345678DEADBEEF" for these first few
  examples.
* I'll fill in the text description after.
* Note: due to my regional location, I might split some tasks into
  more commits in order to be sure no work gets lost in case of
  emergency (or to put it another way: I know Telstra too well to
  trust them).
2018-03-09 04:42:41 +11:00
Ben McGinnes
a98f2c556f doc-howto: fundamental aspects of GPGME vs Python
* Added a section for those pythonistas who are too used to web
  programming.  Stressed that it's not simply not RESTful, it's not
  even REST-like.
* Letting me move on to drawing a very loose parallel between a
  session and a context.  The differences should become obvious in the
  subsequent sections.
2018-03-08 15:23:05 +11:00
Ben McGinnes
e8adab68f8 doc: Added multiple TODOs for inclusion in the HOWTO
* Some instructions to include are fairly obvious; as with encryption,
  decryption and signature verification.
* Some are a little less obvious.
* This includes the requests received to specifically include subkey
  management (adding and revoking subkeys on a primary key that's
  being retained.
* Added the UID equivalents to the list, as well as key selection
  matters (and may or may not include something for handling group
  lines since that involves wrapping a CLI binary).
* Key control documentation and examples requested by Mike Ingle of
  confidantmail.org.
2018-03-08 14:13:00 +11:00
Ben McGinnes
47d401d159 GPL compatible license for documentation
* Added the same, slightly modified GPL based license that is used in
  other parts of GnuPG.
2018-03-07 21:27:54 +11:00
Ben McGinnes
8a76deb11e HOWTO update
* removed one bit of whitespace.
* Marked up references to gpgme.h.
* Fixed one spelling error.
* Removed py2.6 from python search order since even if it is
  supported, it shouldn't be encouraged.
2018-03-07 20:12:26 +11:00
Ben McGinnes
5215d58ae2 GPGME Python bindings HOWTO
* Started work on the GPGME Python bindings HOWTO.
* 1,050 words to begin with at approx. 7.5KB.
* Got as far as installation.
* Includes instruction not to use PyPI for this.
2018-03-07 20:05:21 +11:00
Ben McGinnes
8f2c0f4534 TODO - HOWTO
* Added suv-entry for the new HOWTO being started and, since it has
  been started, checked it off.
2018-03-07 19:13:37 +11:00
Ben McGinnes
d4778bb23d TODO
* Slightly expanded the list.
2018-03-07 17:56:54 +11:00
Ben McGinnes
c58f61e922 WS removal
* Whitespace removal.
2018-02-26 14:09:38 +11:00
Ben McGinnes
6f2e2e0f15 LaTeX headers
* Set LaTeX headers to enable ligatures and a 12pt font by default.
* Paper size left for regional defaults.
* Using XeLaTeX for easier font control.
* Using default LaTeX font of Latin Main, but that's easy enough to change.
2018-02-26 13:51:23 +11:00
Ben McGinnes
272a8e778a Renaming ad infinitum ...
* Dropped the .txt from the end of the file ...
2018-02-20 03:13:42 +11:00
Ben McGinnes
c82b17c6ce Text conversion
* Exported from Org Mode to UTF-8 text.
* Removed my name from just under the title.
2018-02-20 03:11:50 +11:00
Ben McGinnes
ea481d4bb9 Title fix
* Fixed title.
2018-02-20 03:11:02 +11:00
Ben McGinnes
1ae3ead2cd Conflict with Phabricator files
* The developers of Phabricator, the web front-end on dev.gnupg.org
  have not implemented renderers for Markdown, Org-Mode or any other
  common markdown like language.
* They also refuse to do so.
* Instead they re-invented the wheel and implemented their own version
  of Markdown-like thing which is incompatible with everything else.
  It is called Remarkup.
* The developers of Phabricator and Remarkup have refused to provide
  conversion tools to move files to/from any format to/from Remarkup.
* They expect everyone to learn their new favourite pet project.
* Remarkup may or may not display Org Mode files, but if so then it is
  likely to only want to do so as plain text.
* There is an unaffiliated and unofficial project to convert Github
  Markdown to Remarkup via Pandoc.  This might be adapted for our use,
  but requires testing.
* Until then exporting from Org Mode to UTF-8 text is likely the least
  worst plan.
* Which means renaming this file to README.org first.
2018-02-20 02:51:02 +11:00
Ben McGinnes
fe4f3edd70 Schizophrenic file types
* Removed Markdown style heading underlining.
* Removed in-line file type declaration (which is not correctly parsed
  by the web interface on dev.gnupg.org).
2018-02-20 02:45:44 +11:00
Ben McGinnes
fb16eaa685 History path
* Fixed a typo in a filepath reference.
* Moved conjecture regarding the first version of Python used to a
  footnote.
2018-02-16 19:15:32 +11:00
Ben McGinnes
2b092bf235 Merge branch 'master' of /Users/ben/dev/hgit/mine/gnupg/gpgme/master into ben/python-docs-01 2018-02-16 02:04:57 +11:00
Ben McGinnes
6f15d82140 LaTeX margins
* Added LaTeX header for 1 inch margins in the quite likely event that
  all PDF output ultimately uses LaTeX.
2018-02-16 01:26:20 +11:00
Ben McGinnes
235d899a5f TODO Documentation
* Checked off the decision to stick with Org Mode.
2018-02-15 21:30:32 +11:00
Ben McGinnes
40da502292 TODO
* Beginning to turn the first part of this into something kind of like
  an actual TODO list as Org Mode uses it (maybe).
2018-02-15 21:28:07 +11:00
NIIBE Yutaka
b5ec21b9ba tests: Makefile portability.
* tests/gpg/Makefile.am: Don't use "export" directive.
* tests/gpgsm/Makefile.am: Ditto.
* lang/qt/tests/Makefile.am: Ditto.
* lang/python/tests/Makefile.am: Ditto.

--

GnuPG-bug-id: 3056
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2018-02-15 11:14:49 +09:00
NIIBE Yutaka
c9a351f5af build: More Makefile fix.
* lang/python/tests/Makefile.am: Avoid target with '/'.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2018-02-15 10:27:59 +09:00
Ben McGinnes
3c3b149996 Short History
* Fixed or updated the most fundamental errors.
* Also included some details on which modules are available on PyPI,
  as well as what happened to the PyME commit log.
2018-02-15 04:19:15 +11:00
Ben McGinnes
7c662d22a8 Subsectioned history
* Split the main parts down into subsections.
* Still need to cull the incorrect stuff towards the end and add more
  recent changes.
2018-02-15 01:03:12 +11:00
Ben McGinnes
a1bc710c5f History
* Reshaping the history file to fit Org Mode's structuring for docs.
* Also said history needs to be a bit more clear (it was kind of
  unfinished).
2018-02-14 22:44:27 +11:00
Ben McGinnes
fccd2ea387 TODO
* Updated TODO.
* The entirety of the old TODO has been replaced with either more
  relevant tasks or goals for the examples and a more measured
  approach to the docs and why, in this project, Org Mode trumps reST,
  even though it's Python through and through.
2018-02-14 22:28:50 +11:00
Ben McGinnes
487ed9337e TODO
* Removed reST version of file.
2018-02-14 21:25:45 +11:00
Ben McGinnes
c4fa421619 TODO
* Converted document from reST to org-mode.
2018-02-14 21:24:54 +11:00
Ben McGinnes
1d48b04cfb Short History
* Removed reST version.
2018-02-14 21:23:04 +11:00
Ben McGinnes
d86fd7c54c Short History
* Converted document from reST to org-mode.
2018-02-14 21:21:58 +11:00
Andre Heinecke
7b5182f288
Spelling fixes for comments and doc
--
Patch provided by ka7 in dev.gnupg.org

Differential D423
2017-12-08 05:59:11 +01:00
Tobias Mueller
3cf9aedc92
python: Default whence argument for Data() to SEEK_SET.
* lang/python/gpgme.i: copied signature from gpgme.h and defaulted the
value to SEEK_SET.
* lang/python/tests/t-data.py: Added a test for no second argument
--

Having to import the os package when wanting to read a Data object is a
slight annoyance. With SWIG, we can define default parameters. This
change defaults the whence argument to SEEK_SET which is how StringIO
and BytesIO behave.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2017-12-04 08:10:06 +01:00
NIIBE Yutaka
c441fb7313 tests: Make portability fix.
* lang/python/tests/Makefile.am: Distinguish target and path.
* tests/gpg/Makefile.am: Ditto.
* tests/gpgsm/Makefile.am: Ditto.

--

GNU Make is powerful enough to match path to target (and vice versa),
but BSD make is not.

GnuPG-bug-id: 3056
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-11-21 15:35:10 +09:00
Alon Bar-Lev
57c1259308
python: Support parallel build in tests
* lang/python/tests/Makefile.am: Depend xcheck with all which was lost
due to the check hack.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-08-21 10:55:10 +02:00
Justus Winter
70c8be9efe
python: Improve keylist test.
* lang/python/tests/t-keylist.py: Check a keylist matching no keys.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-08-21 10:54:10 +02:00
Justus Winter
1e68f93dc5
python: Improve error handling.
* NEWS: Update.
* lang/python/src/core.py (Context.__read__): New helper function.
(Context.encrypt): Attach partial results to exceptions.
(Context.decrypt): Likewise.
(Context.sign): Likewise.
(Context.verify): Likewise.
* lang/python/src/errors.py (GpgError): Move the core of GPGMEError to
this class, add a nicer interface for it.  This makes the errors
thrown by this library more uniform, and allows us to track the
underlying error in synthesized high-level errors.
(GPGMEError): Simplify.
(...): Make sure to call the parent classes' constructor in all other
classes.
--

Attach partial results to errors.  Some operations return results even
though they signal an error.  Of course this information must be taken
with a grain of salt.  But often, this information is useful for
diagnostic uses or to give the user feedback.  Since the normal
control flow is disrupted by the exception, the callee can no longer
return results, hence we attach them to the exception objects.

GnuPG-bug-id: 3271
Signed-off-by: Justus Winter <justus@g10code.com>
2017-07-11 12:28:39 +02:00
Justus Winter
05fa2a9c77
Add flag 'is_de_vs' to decryption results and signatures.
* NEWS: Update.
* lang/cpp/src/decryptionresult.cpp (DecryptionResult::isDeVs): New
function.
* lang/cpp/src/decryptionresult.h (DecryptionResult::isDeVs): New
prototype.
* lang/cpp/src/verificationresult.cpp (Signature::isDeVs): New
function.
* lang/cpp/src/verificationresult.h (Signature::isDeVs): New
prototype.
* lang/python/src/results.py (DecryptResult): Turn field 'is_de_vs'
into a boolean.
(Signature): Likewise.
* src/decrypt.c (_gpgme_decrypt_status_handler): Handle the new
compliance status line.
* src/verify.c (_gpgme_verify_status_handler): Likewise.
* src/gpgme.h.in (gpgme_status_code_t): Add new status codes for the
new status lines.
* src/keylist.c (parse_pub_field18): Move function to 'util.h'.
(keylist_colon_handler): Adapt callsites.
* src/status-table.c (status_table): Add new status lines.
* src/util.h (PARSE_COMPLIANCE_FLAGS): New macro.  This used to be
'parse_pub_field18', but turned into a macro to make it polymorphic.
--

When decrypting data and verifying signatures, report whether the
operations are in compliance with the criteria for data classified as
VS-NfD.  This information can the be presented to the user.

GnuPG-bug-id: 3059
Signed-off-by: Justus Winter <justus@g10code.com>
2017-06-01 14:16:11 +02:00
Justus Winter
84a203e60b
python: Fix build in certain cases.
* lang/python/setup.py.in: Prepend the Python build dir to the list of
include directories so that it takes precedence over any other include
directory.
--
Fixes the build in case an older 'gpgme.h' is installed and is picked
up by the compiler when compiling the Python module.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-05-18 12:22:29 +02:00
Justus Winter
6b4dd3b929
python: Fix test environment creation.
* lang/python/tests/Makefile.am (pubring-stamp): Do not depend on the
configuration files, this can trigger superfluous rebuilds.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-05-10 16:19:52 +02:00
Justus Winter
a226eca846
tests: Make sure to kill all previously running daemons.
* lang/python/tests/Makefile.am: Kill all previously running daemons
before creating the private key store.
* lang/qt/tests/Makefile.am: Likewise.
* tests/gpg/Makefile.am: Likewise.
* tests/gpgsm/Makefile.am: Likewise.
--

Now that the daemons sockets are no longer created in the GNUPGHOME,
we cannot rely on cleaning the build directory to make sure they are
shut down.  Therefore, we explicitly kill any running daemons when
creating the test environment.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-05-10 15:52:12 +02:00
Justus Winter
15adff073b
tests: Harmonize test suites.
* lang/python/tests/Makefile.am: Create test environment as part of
'make all'.
* tests/gpg/Makefile.am: Make sure the private keystore is created
first.
* tests/gpgsm/Makefile.am: Create test environment as part of
'make all'.  Make sure the private keystore is created
first.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-05-10 15:49:54 +02:00
Justus Winter
979d48e823
python: Skip TOFU test if not supported by GnuPG.
* lang/python/tests/support.py (have_tofu_support): New function.
* lang/python/tests/t-quick-key-manipulation.py: Skip TOFU test if not
supported by GnuPG.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-04-11 12:24:41 +02:00
Alon Bar-Lev
a827382caf
python: use autoconf pre-processor when building via autoconf
* configure.ac: Add AC_PROG_CPP.
* lang/python/Makefile.am: Set CPP environment for setup.py to use.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-04-11 10:24:44 +02:00
Alon Bar-Lev
d785c053a9
python: fix run-tests missing python_libdir
* lang/python/tests/run-tests.py: Set python_libdir if --python-libdir
is set.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-04-11 10:16:47 +02:00
Justus Winter
63bec9f486
python: Prune CLEANFILES.
--
Fixes-commit: e7d9c0c3d7
Signed-off-by: Justus Winter <justus@g10code.com>
2017-04-10 15:24:03 +02:00
Justus Winter
db476e9234
python: Fix distcheck.
* lang/python/Makefile.am (uninstall-local): Explicitly request the
scheme 'posix_prefix'.  On Python2.7 the default scheme is
'posix_local', breaking distcheck.

Fixes-commit: 25e6444b3f
Signed-off-by: Justus Winter <justus@g10code.com>
2017-04-10 15:20:34 +02:00
Alon Bar-Lev
3cc90b67fa
python: Support alternatate libdir for tests
* lang/python/tests/run-tests.py: Add --python-libdir optional
parameter.

--

This will make the python tests usable for downstream that build python
module outside of autotools build system.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-04-10 14:48:03 +02:00
Alon Bar-Lev
7309ce6f5f
python: Read gpg-error.h using the pre-processor
* lang/python/setup.py.in: Read gpg-error.h using the pre-processor.

--

The libgpg-error may be installed in multilib configuration in which
there is a wrapper header at /usr/include that includes the actual
header at /usr/include/*. This causes invalid errors.i generation.

Let the pre-processor extract the header content instead reading it
explicitly.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-04-10 14:47:44 +02:00
Alon Bar-Lev
df8433bffa
python: Remove unneeded stats copy
* lang/python/setup.py.in: errors.i, gpgme.h are generated and always
newer than the original.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-04-10 14:44:33 +02:00
Alon Bar-Lev
25e6444b3f
python: Remove usage of PYTHON_VERSIONS
* configure.ac: Remove PYTHON_VERSIONS subst.
* lang/python/Makefile.am: Use basename of python as builddir prefix.
* lang/python/tests/run-tests.py: Likewise.

--

Two variables needs be at sync PYTHONS and PYTHON_VERSIONS, these may go
out of sync in some cases, for example in Gentoo where default python is
3.4 we get:

PYTHON='/usr/bin/python2'
PYTHONS='/usr/bin/python /usr/bin/python2'
PYTHON_VERSIONS='2.7 3.4'

We can use the basename of the python interpreter to achieve similar
effect without having to sync indexes between these two variables.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-04-10 14:44:16 +02:00
Alon Bar-Lev
365c649ad0
python: support .pydistutils.cfg mode
* lang/python/setup.py.in: Do not parse arguments.

--

The distutils settings can come from either command-line or
configuration file. Parsing parameters is not working in all cases.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-04-10 14:35:35 +02:00
Alon Bar-Lev
49195c487e
python: simplify build, some fixups
* lang/python/gpg/version.py.in: Rename to lang/python/version.py.in.
configure.ac: Generate version.py.in in lang/python.
* lang/python/MANIFEST.in: Include version.py explicitly.
* lang/python/gpg: Rename to 'src'.
* lang/python/Makefile.am: Do not copy source files, do not use absolute
directories, support lib64 in uninstall, clean also dist directory, use
symlink for gpg src.
* lang/python/setup.py.in: Use builddir, copy sources into builddir,
copy version.py into module.
--

Simplify build to symlink the gpg sources into builddir instead of
copying. This requires handling of version.py as generated file.

In addition apply some cleanups: Drop the absolution pathes, clean the
dist directory as well, support lib64 for sitelib at uninstall.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-04-07 12:12:20 +02:00
Justus Winter
e7d9c0c3d7
python: Fix vpath builds, fix distcheck.
* lang/python/gpgme-h-clean.py: Delete file.
* lang/python/MANIFEST.in: Adapt accordingly.
* lang/python/Makefile.am (EXTRA_DIST): Likewise.
(COPY_FILES_GPG): Bring variable back.
(copystamp): Copy files.
(clean-local): Delete copied files.
(install-exec-local): Do not create and install list of installed
files.
(uninstall-local): Instead, create some explicit rules to uninstall
the extension.
* lang/python/setup.py.in: Parse arguments.  Locate files either in
the source directory, or in the build base directory.  Inline the code
from 'gpgme-h-clean.py'.  Copy 'helpers.c', add source directory as
include directory.

Fixes-commit: 801d7d8c5d
Signed-off-by: Justus Winter <justus@g10code.com>
2017-04-05 16:41:56 +02:00
Alon Bar-Lev
801d7d8c5d
python: Generate files into build directory
* lang/python/setup.py.in: Generate files within BuildExtFirstHack
adjust build flags at this point instead of global.
* lang/python/Makefile.am: Remove logic of separate source directory per
python version in favor of build directory.
* lang/python/tests/run-tests.py: Adjust build directory location.
--

Generate files into build directory, leaving the source directory clean.
Use the same source directory for multiple python version build. Result
of 'prepare' target is a standard distutil layout that can be used
easily by downstream to build all python targets in-place.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-04-05 14:48:47 +02:00
Andre Heinecke
f8a9ecc629
python: Don't treat skipped tests as error
* lang/python/tests/run-tests.py (failed): Don't count skipped tests
for the return code.
2017-03-30 16:22:20 +02:00
Justus Winter
159505a288
python: Fix skipping tests if running with GnuPG < 2.1.12.
* final.py: Import 'support.py' for the side-effect of checking the
GnuPG version.
* t-data.py: Likewise.
* t-protocol-assuan.py: Likewise.
* t-wrapper.py: Likewise.
* t-callbacks.py: Avoid warning about 'support' being unused.
* t-edit.py: Likewise.
* t-encrypt-sym.py: Likewise.
* t-file-name.py: Likewise.
* t-idiomatic.py: Likewise.
* t-sig-notation.py: Likewise.
* t-trustlist.py: Likewise.
* t-verify.py: Likewise.
* t-wait.py: Likewise.
* t-keylist-from-data.py: Trim unused imports.

GnuPG-bug-id: 3008
Fixes-commit: 348da58fe0
Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-30 15:06:10 +02:00
Alon Bar-Lev
9786e3a96e
python,build: Reinstate prepare target.
* lang/python/Makefile.am: Fix 'prepare' target.
* lang/python/setup.py.in: Use 'abs_top_builddir' instead of guessing
the path.
--

'prepare' will prepare target at PREPAREDIR.  The automake integration
will also make use of prepare target.  Downstream distributors may
also make use of prepare target.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2017-03-29 11:28:18 +02:00
Justus Winter
348da58fe0
python: Skip tests if running with GnuPG < 2.1.12.
* lang/python/tests/support.py (assert_gpg_version): Fix error
message.  Skip all tests when we use GnuPG older than 2.1.12.

GnuPG-bug-id: 3008
Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-27 11:11:47 +02:00
Justus Winter
f3e8d8a451
python: Wrap 'gpgme_op_keylist_from_data_start'.
* NEWS: Update.
* lang/python/gpg/core.py (Context.keylist): New keyword argument
'source'.  If given, list keys from 'source'.
* lang/python/gpgme.i: Wrap the argument to
'gpgme_op_keylist_from_data_start'.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/support.py (EphemeralContext): Do not throw an
error if no agent has been started in the context.
* lang/python/tests/t-keylist-from-data.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-21 12:55:33 +01:00
Justus Winter
57e64d019d
python: Fix version check.
* lang/python/tests/support.py (assert_gpg_version): Cope with
non-released versions.

Fixes-commit: e1cf8bab31
Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-20 16:53:29 +01:00
Justus Winter
16b202d999
tests: Use 'gpg-agent --allow-loopback-pinentry' if applicable.
* lang/python/tests/Makefile.am (gpg-agent.conf): Do not hard-code the
option.  This breaks gpg-agent from GnuPG 2.0.
* tests/start-stop-agent: Rather, check if the option is supported and
add it to the configuration if it is.

GnuPG-bug-id: 3008
Fixes-commit: bbf19124bb
Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-20 16:41:43 +01:00
Justus Winter
e1cf8bab31
python: Skip tests if GnuPG is too old.
* lang/python/tests/support.py (assert_gpg_version): New function.
* lang/python/tests/t-callbacks.py: Use the new function to skip the
test if GnuPG is too old.
* lang/python/tests/t-edit.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-quick-key-creation.py: Likewise.
* lang/python/tests/t-quick-key-manipulation.py: Likewise.
* lang/python/tests/t-quick-key-signing.py: Likewise.

GnuPG-bug-id: 3008
Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-20 16:20:02 +01:00
Justus Winter
4572e8d2ac
python: Remove superfluous initialization.
* lang/python/tests/support.py (init_gpgme): Remove.  This is an
remnant from the c tests.  Nowadays, the Python bindings initialize
GPGME automagically.
* lang/python/tests/initial.py: Remove call to 'support.init_gpgme'.
* lang/python/tests/t-callbacks.py: Likewise.
* lang/python/tests/t-decrypt-verify.py: Likewise.
* lang/python/tests/t-decrypt.py: Likewise.
* lang/python/tests/t-edit.py: Likewise.
* lang/python/tests/t-encrypt-large.py: Likewise.
* lang/python/tests/t-encrypt-sign.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-encrypt.py: Likewise.
* lang/python/tests/t-export.py: Likewise.
* lang/python/tests/t-file-name.py: Likewise.
* lang/python/tests/t-idiomatic.py: Likewise.
* lang/python/tests/t-import.py: Likewise.
* lang/python/tests/t-keylist.py: Likewise.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-sign.py: Likewise.
* lang/python/tests/t-signers.py: Likewise.
* lang/python/tests/t-trustlist.py: Likewise.
* lang/python/tests/t-verify.py: Likewise.
* lang/python/tests/t-wait.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-20 16:07:07 +01:00
Justus Winter
9d6825be09
python: Make error message more helpful.
* lang/python/tests/run-tests.py: Make the error message shown when we
cannot locate the python module in the build tree more helpful.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-14 12:20:25 +01:00
Justus Winter
ac48499538
python: Make tests more robust.
* lang/python/tests/support.py (TemporaryDirectory): Always use our
own version even if 'tempfile.TemporaryDirectory' is provided, because
we need to use 'shutil.rmtree(..., ignore_errors=True)' to avoid it
tripping over gpg-agent deleting its own sockets.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-14 12:20:24 +01:00
Justus Winter
a4201035fd
python: Improve build system integration.
* lang/python/Makefile.am: Use 'set -e' when chaining shell commands
together in rules.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-14 12:20:21 +01:00
Justus Winter
41398779ab
python: Print path of the Python module used during tests.
* lang/python/tests/initial.py: Print path of the Python module used
during tests.  Useful to detect if by any mistake the wrong module is
picked up.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-03-02 16:06:29 +01:00
Justus Winter
a7c6353eda
python: Fix test.
* lang/python/tests/t-quick-key-manipulation.py: Modify the
configuration file in the ephemeral home directory, not the one used
by all the tests.

Fixes-commit: 15fbac9e72
Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-20 10:23:41 +01:00
Justus Winter
15fbac9e72
python: Support manipulating the TOFU policy.
* NEWS: Update.
* doc/gpgme.texi: Fix typos.
* lang/python/gpg/constants/__init__.py: Import new files.
* lang/python/gpg/constants/tofu/__init__.py: New file.
* lang/python/gpg/constants/tofu/policy.py: New file.
* lang/python/gpg/core.py (Context.key_tofu_policy): New function.
* lang/python/gpgme.i: Nice reprs for gpgme_tofu_info_t.
* lang/python/setup.py.in: Install new package.
* lang/python/tests/t-quick-key-manipulation.py: Extend test.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-17 17:08:03 +01:00
Justus Winter
48634e651f
python: Support quick key signing.
* NEWS: Update.
* doc/gpgme.texi (gpgme_op_keysign): Fix the description of the
'expire' argument.
* lang/python/gpg/constants/__init__.py: Import new file.
* lang/python/gpg/constants/keysign.py: New file.
* lang/python/gpg/core.py (Context.key_sign): New function.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/t-quick-key-signing.py: New test.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-17 16:28:00 +01:00
Justus Winter
de8494b16b
python: Fix teardown of ephemeral contexts.
* lang/python/tests/support.py (EphemeralContext): New function.
* lang/python/tests/t-quick-key-creation.py: Use the new function to
manage ephemeral contexts.
* lang/python/tests/t-quick-key-manipulation.py: Likewise.
* lang/python/tests/t-quick-subkey-creation.py: Likewise.
--

Previously, there was a problem with cleaning up ephemeral home
directories.  shutil.rmtree deleted the agents main socket, gpg-agent
detected that, and deleted the other sockets as well, racing
shutil.rmtree which did not cope will with that.

Fix this by asking the agent nicely to shut down.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-17 12:18:56 +01:00
Justus Winter
9350168a1e
python: Fix using strings as commands in the assuan protocol.
* lang/python/gpg/core.py (Context.assuan_transact): Fix testing
whether the command is a string on Python2.
* lang/python/tests/t-protocol-assuan.py: Improve the test to detect
this problem.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-17 12:10:34 +01:00
Justus Winter
7641b7b5f2
python: Support adding and revoking UIDs.
* NEWS: Update.
* lang/python/gpg/core.py (Context.key_add_uid): New function.
(Context.key_revoke_uid): Likewise.
* lang/python/tests/Makefile.am (XTESTS): Add new test.
* lang/python/tests/t-quick-key-manipulation.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-16 17:55:16 +01:00
Justus Winter
13bace25e3
python: Support quick subkey creation.
* NEWS: Update.
* lang/python/gpg/core.py (Context.create_subkey): New function.
* lang/python/tests/Makefile.am (XTESTS): Add new test.
* lang/python/tests/t-quick-subkey-creation.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-16 16:45:25 +01:00
Justus Winter
476b97822b
python: Support quick key creation.
* NEWS: Update.
* lang/python/gpg/constants/__init__.py: Import new file.
* lang/python/gpg/constants/create.py: New file.
* lang/python/gpg/core.py (Context.create_key): New function.
* lang/python/tests/Makefile.am (XTESTS): Add new test.
* lang/python/tests/support.py (TemporaryDirectory): New class.
* lang/python/tests/t-quick-key-creation.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-16 16:43:10 +01:00
Justus Winter
3bdce4aa3d
python: Fix passphrase callback wrapping.
* lang/python/helpers.c (pyPassphraseCb): Cope with 'passphrase_info'
being NULL.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-16 14:49:27 +01:00
Justus Winter
048c5f74b6
python: Fix error handling.
* lang/python/gpgme.i (typemap gpgme_key_t[]): Set an error if a
non-key element is discovered.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-16 14:42:17 +01:00
Justus Winter
27544d0a74
python: Fix build system integration.
* lang/python/Makefile.am (copystamp): Also copy the setup script, and
link the header files.
(all-local): Use local setup script.
(sdist): Fix Python source distribution creation.
(CLEANFILES): Remove now obsolete files.
(install-exec-local): Use local setup script.
* lang/python/setup.py.in: Adjust relative paths to in-tree files.

Fixes-commit: fe65a26ab5
Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-15 16:36:30 +01:00
Justus Winter
25f0435a00
python: Update lists of functions returning gpgme_error_t.
* lang/python/gpg/core.py (Context._errorcheck): Add instructions how
to update the list.  Update list.
(Data._errorcheck): Likewise.
(Context.set_engine_info): Simplify.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-15 16:36:29 +01:00
Justus Winter
92adc9bbf6
python: Wrap utility functions.
* NEWS: Update.
* lang/python/gpg/core.py (pubkey_algo_string): New function.
(pubkey_algo_name): Add docstring.
(hash_algo_name): Likewise.
(get_protocol_name): Likewise.
(addrspec_from_uid): New function.
* lang/python/gpgme.i (gpgme_pubkey_algo_string): Result must be
freed.
(gpgme_addrspec_from_uid): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-14 16:33:55 +01:00
Justus Winter
9fc9533c28
python: Use the correct function to free buffers.
* lang/python/gpgme.i (char *): Free using 'gpgme_free'.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-14 16:33:54 +01:00
Justus Winter
fdc4e33dc3
python: Add keylist mode parameter.
* NEWS: Update.
* lang/python/gpg/core.py (Context.keylist): Add 'mode' parameter.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-14 16:33:40 +01:00
Justus Winter
e17ab84129
python: Nicer repr for user ids.
* lang/python/gpgme.i (_gpgme_user_id): Provide a nicer repr() for
user ids.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-14 16:33:37 +01:00
Justus Winter
99b7f4f34d
python: Add convenience functions for the home directory.
* NEWS: Update.
* lang/python/gpg/core.py (Context.__init__): Add 'home_dir' argument.
(__repr__): Include 'home_dir'.
(Context.home_dir): New property.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-14 16:33:19 +01:00
Tobias Mueller
01d5c17587
python: Extend SWIG gpgme_{sub,}key with a __repr__ method.
* lang/python/gpgme.i: Added a genericrepr macro and use it for
gpgme_key, gpgme_subkey, and gpgme_key_sig.
--

To look nicer in Python's REPL.

We define a generic __repr__ as a SWIG macro and use that to extend some
defined SWIG objects.

The alternative would have been to write a custom __repr__ function for
each class but that would need to be changed everytime the object's
structure changes. The bindings should be easy to maintain, I guess.
This comes at the expense that the reprs are now relatively long and
contain, for example, both keyid and fingerprint.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2017-02-14 11:19:50 +01:00
Tobias Mueller
aa49be1ab8
python: Remove the -builtin flag for SWIG.
* lang/python/setup.py.in: Call SWIG without the builtin flag.
--

The SWIG documentation
<http://www.swig.org/Doc2.0/Python.html#Python_nn28> leaves the
impression that -builtin is solely for increasing performance:

    New in SWIG version 2.0.4: The use of Python proxy classes has
    performance implications that may be unacceptable for a high-
    performance library. The new -builtin option instructs SWIG to
    forego the use of proxy classes, and instead create wrapped types as
    new built-in Python types. When this option is used, the following
    section ("Proxy classes") does not apply. Details on the use of the
    -builtin option are in the Built-in Types section.

While not wasting CPU cycles is good, it also prevents Python code being
written in the wrapper itself. That, however, may be useful to make it
easier to extend the wrapper.

Partially reverts: 856bcfe293

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2017-02-14 11:19:45 +01:00
Tobias Mueller
d356519170
python: Call SWIG_NewPointerObj rather than SWIG_Python_NewPointerObj.
* lang/python/gpgme.i (pygpgme_wrap_gpgme_data_t): Provide a "self"
variable for SWIG_NewPointerObj and call SWIG_NewPointerObj rather than
SWIG_Python_NewPointerObj.
--

SWIG_Python_NewPointerObj seems to be an implementation detail, because
SWIG's documentation does not mention that function at all.  In fact,
SWIG_NewPointerObj is a call to SWIG_Python_NewPointerObj with the first
parameter being either NULL or the "self" variable, depending on whether
SWIG is called with the -builtin flag.  So far, the first parameter was
hard-coded to NULL.  This change also hard-codes it to NULL but makes
it more explicit.  The benefit is that the documented function is being
used and that compilation works regardless of the -builtin flag.

Partially reverts: 856bcfe293

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2017-02-14 11:19:17 +01:00
Tobias Mueller
d184dbbba8
python: Conditionally provide py3 argument to SWIG
* lang/python/setup.py.in: Only call with -py3 when we run under python3
or higher.
--

If we ever remove the -builtin flag and leave the the -py3 flag, SWIG
will generate Python code which will be incompatible with Python 2,
because the py3 flag generates python3 code which is incompatible with
python2.

So we conditionally generate SWIG bindings with -py3.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2017-02-14 11:19:12 +01:00
Justus Winter
fe65a26ab5
python: Use one copy of the source tree per Python version.
* lang/python/Makefile.am (copystamp): Create one copy per Python
version.
(all-local): Adapt.
(clean-local): Likewise.
(install-exec-local): Likewise.
* lang/python/tests/run-tests.py: Likewise.
--

Currently, we use one copy of the Python module's source to build for
all Python versions.  This is problematic, because SWIG writes a
wrapper file into the source tree.  Currently, this file works with
both Python 2 and 3, but this is purely by chance.

Improve the situation by creating one copy per Python version so that
SWIG can write version-specific code into each copy.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-13 16:44:53 +01:00
Andre Heinecke
f3ca2c9ce9 python: Ensure quick-random is used if gpg is gpg2
* lang/python/tests/Makefile.am (gpg.conf): Configure
agent-program accordingly.
2017-01-26 10:44:02 +01:00
Tobias Mueller
9291ebaa41 python: default op_keylist_start parameters.
* lang/python/gpgme.i: Added gpgme_op_keylist_start with defaults
* lang/python/tests/t-keylist.py: Added tests for default parameters
--

To increase the ease of use, op_keylist_start
parameters default to sensible values.
The empty string matches all keys.
We assume that the user wants to retrieve public keys most of the time,
so we default to public keys rather than secret keys.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2017-01-25 17:47:35 +01:00
Justus Winter
b14419f68b python: Improve compatibility with Scheme tests.
* lang/python/tests/run-tests.py: Add stub --parallel option.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-03 15:29:01 +01:00
Justus Winter
d0e91d28f6 python: Add a switch '--quiet' to the test runner.
* lang/python/tests/run-tests.py: Add and honor a switch '--quiet'.
This way we can use this script to run Python tests one by one without
the noise, and the script will setup the necessary environment for us.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-03 15:28:36 +01:00
Tobias Mueller
05896c210f python: Try to be more helpful when given a string to encrypt().
* lang/python/helpers.c (_gpg_obj2gpgme_data_t): Extended error
message.
* lang/python/tests/t-encrypt.py: Test for "encode" in error message.
--
The motivation is to help the user when encrypting fails. I claim that
it is not obvious to not being able to encrypt a string directly.  To
nudge the user into encoding it to bytes, the error message is a bit
extended.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2016-12-05 12:44:20 +01:00
Tobias Mueller
fb7f4cb973 python: Define a macro for wrapping fragile result objects.
* lang/python/gpgme.i (wrapresult): New Macro.
--

This reduces the amount of copy and pasted code at the expense of a
slightly more complicated logic with a macro.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2016-12-05 12:41:45 +01:00
Tobias Mueller
ae21d2705f python: Check "buffer" when writing to sys.stdout for python2 compat.
* lang/python/tests/support.py (print_data): Add check for buffer.
--

When running with something like make -C lang/python check verbose=2 the
test would fail under python2, because the file objects do not have a
buffer property.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2016-12-01 17:39:38 +01:00
Tobias Mueller
154389f2a5 python: Make Context have a repr method.
* lang/python/gpg/core.py (Context.__repr__): New function.
--

This makes Context objects look nicer in a REPL.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2016-12-01 17:37:15 +01:00
Tobias Mueller
db2f6c1ca3 python: Make Results have a nicer __repr__.
* lang/python/gpg/results.py (Result.__str__): Renamed to '__repr__'
...
* lang/python/gpg/results.py (Result.__repr__): ... and added fields.
--

So that it looks a bit nicer in the Python REPL.

It looked like this before:

In [2]: gpg.core.get_engine_info()[0]
Out[2]:
<gpg.results.EngineInfo at 0x7fb23509a240>

Now the output is

In [2]: gpg.core.get_engine_info()[0]
Out[2]:
EngineInfo(file_name='/usr/bin/gpg2', home_dir=None,
protocol=0, req_version='1.4.0', version='2.1.11')

This also applies to other results, e.g. the ImportResult.

Note that the format now changed from "<Class >" to "Class()". The
Python documentation on repr states: "For many object types, including
most builtins, eval(repr(obj)) == obj."

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
2016-12-01 17:28:39 +01:00
Justus Winter
fd4d476214 python: Fix removing the TOFU database.
* lang/python/Makefile.am (CLEANFILES): Move 'tofu.db'...
* lang/python/tests/Makefile.am (CLEANFILES): ... here.

Fixes-commit: 9b22f82afc
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-25 09:55:42 +01:00
Justus Winter
9b22f82afc tests: Remove tofu.db.
* lang/python/Makefile.am (CLEANFILES): Add 'tofu.db'.
* tests/gpg/Makefile.am (CLEANFILES): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-25 09:13:01 +01:00
Alon Bar-Lev
41d8c7e51a
tests,python: Atomic directory creation
* lang/python/tests/Makefile.am:  Use MIDIR_P.
* tests/gpg/Makefile.am: Ditto.
* tests/gpgsm/Makefile.am: Ditto.

--
Solves race in parallel build when mkdir fails if directory exists.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>

- Tweaked the ChangeLog

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-11-11 09:09:40 +01:00
Justus Winter
f1f341062e python: Require at least GPGME 1.7 for out-of-tree builds.
* lang/python/setup.py.in: Bump required version to 1.7.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-09 13:57:05 +01:00
Justus Winter
4b32643450 python: Use vanity modules for constants in tests and examples.
* lang/python/gpg/constants/sig/notation.py: New file.
* lang/python/gpg/constants/sig/__init__.py: Import new module.

* lang/python/examples/assuan.py: Use more specific module for
constants, e.g. 'protocol.ASSUAN' instead of 'PROTOCOL_ASSUAN'.
* lang/python/examples/testCMSgetkey.py: Likewise.
* lang/python/tests/initial.py: Likewise.
* lang/python/tests/t-callbacks.py: Likewise.
* lang/python/tests/t-decrypt-verify.py: Likewise.
* lang/python/tests/t-decrypt.py: Likewise.
* lang/python/tests/t-edit.py: Likewise.
* lang/python/tests/t-encrypt-large.py: Likewise.
* lang/python/tests/t-encrypt-sign.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-encrypt.py: Likewise.
* lang/python/tests/t-export.py: Likewise.
* lang/python/tests/t-file-name.py: Likewise.
* lang/python/tests/t-idiomatic.py: Likewise.
* lang/python/tests/t-import.py: Likewise.
* lang/python/tests/t-keylist.py: Likewise.
* lang/python/tests/t-protocol-assuan.py: Likewise.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-sign.py: Likewise.
* lang/python/tests/t-signers.py: Likewise.
* lang/python/tests/t-trustlist.py: Likewise.
* lang/python/tests/t-verify.py: Likewise.
* lang/python/tests/t-wait.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-31 15:42:35 +01:00
Justus Winter
20dc37a0e7 python: Import the topmost module in tests and examples.
* examples/verifydetails.py: Only import the topmost module 'gpg' and
update the code accordingly.
* tests/support.py: Likewise.
* tests/t-callbacks.py: Likewise.
* tests/t-data.py: Likewise.
* tests/t-decrypt-verify.py: Likewise.
* tests/t-decrypt.py: Likewise.
* tests/t-edit.py: Likewise.
* tests/t-encrypt-large.py: Likewise.
* tests/t-encrypt-sign.py: Likewise.
* tests/t-encrypt-sym.py: Likewise.
* tests/t-encrypt.py: Likewise.
* tests/t-export.py: Likewise.
* tests/t-file-name.py: Likewise.
* tests/t-import.py: Likewise.
* tests/t-keylist.py: Likewise.
* tests/t-sig-notation.py: Likewise.
* tests/t-sign.py: Likewise.
* tests/t-signers.py: Likewise.
* tests/t-trustlist.py: Likewise.
* tests/t-verify.py: Likewise.
* tests/t-wait.py: Likewise.
* tests/t-wrapper.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-31 15:42:35 +01:00
Justus Winter
70b7064e5c python: Improve constants module.
* lang/python/gpg/constants/__init__.py: Import all modules below
'constants/'.  Interface hygiene: delete 'util'.
* lang/python/gpg/constants/data/encoding.py: Delete 'util'.
* lang/python/gpg/constants/event.py: Likewise.
* lang/python/gpg/constants/import.py: Likewise.
* lang/python/gpg/constants/keylist/mode.py: Likewise.
* lang/python/gpg/constants/md.py: Likewise.
* lang/python/gpg/constants/pk.py: Likewise.
* lang/python/gpg/constants/protocol.py: Likewise.
* lang/python/gpg/constants/sig/mode.py: Likewise.
* lang/python/gpg/constants/sigsum.py: Likewise.
* lang/python/gpg/constants/validity.py: Likewise.
* lang/python/gpg/errors.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-31 15:42:35 +01:00
Daniel Kahn Gillmor
2fac017618 python: Rename Python module from PyME to gpg.
This follows weeks of discussion on the gnupg-devel mailing list.
Hopefully it will make it easier for people using Python to use GnuPG
in the future.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-10-31 15:42:27 +01:00
Werner Koch
c6cab5a2bd
python: Call ln(1) in a portable way.
* lang/python/Makefile.am: Specify target dir for ln.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-10-14 16:32:59 +02:00
Justus Winter
f526d0e22e
python: Make 'get_key' more idiomatic.
* lang/python/pyme/core.py (Context.get_key): Raise errors.KeyNotFound
if the key is not found.  This error is both a KeyError for idiomatic
error handling as well as a GPGMEError so we don't break existing
code.
* lang/python/pyme/errors.py (KeyNotFound): New class.
* lang/python/tests/support.py (no_such_key): New variable.
* lang/python/tests/t-keylist.py: Test the new behavior.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-13 13:19:49 +02:00
Justus Winter
1e6073ffa9
python: Return public keys by default.
* lang/python/pyme/core.py (Core.get_key): Return public keys by
default, improve docstring.
* lang/python/examples/testCMSgetkey.py: Update example.
* lang/python/examples/verifydetails.py: Likewise.

GnuPG-bug-id: 2751
Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-13 13:19:47 +02:00
Justus Winter
cabd4c74e5
python: Fix example.
* lang/python/examples/inter-edit.py: Fix example.

Fixes-commit: a458e7fe
Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-13 13:19:46 +02:00
Alon Bar-Lev
453ab9d24c python: Link 'data.h' and 'config.h' into the builddir.
* lang/python/Makefile.am: Link to the files.
* lang/python/gpgme.i: Update path.
* lang/python/setup.py.in: Do not add the top builddir to the include
path.
--
To make it easy to build the subpackage using standard tools without
altering environment or CFLAGS, symlink the required artifacts from
source tree into subpackage directory when preparing sources.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2016-09-30 14:47:26 +02:00
Alon Bar-Lev
68fb8371a1 python: Add 'prepare' target.
* lang/python/Makefile.am: Add 'prepare' target.
--
This enables preparing the package using autoconf then build using
distutils as separate stage.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2016-09-30 14:46:28 +02:00
Justus Winter
a6e9eefb23 tests: Fix blunder.
--
Fixes-commit: a423603f
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-27 12:49:24 +02:00
Justus Winter
a423603f80 tests: Fix check for gpg versions not reporting the critical flag.
* lang/python/tests/t-sig-notation.py: Also blacklist 2.0.x.
* tests/gpg/t-sig-notation.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-27 12:31:18 +02:00
Justus Winter
c9934bb1ee python: Get rid of the last C++-style comments.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-26 16:54:58 +02:00
Justus Winter
c38fabfea0 python: Correctly translate to size_t.
* lang/python/gpgme.i: Correctly translate Python number to size_t.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-26 16:54:58 +02:00
Justus Winter
1d80e7374a python: Correctly translate off_t.
* lang/python/gpgme.i: Improve int/long translations, correctly handle
off_t with large file support.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-26 16:54:58 +02:00
Justus Winter
3703a47238 python: Include 'config.h'.
* lang/python/Makefile.am: Pass 'top_builddir' to 'setup.py'.
* lang/python/gpgme.i: Include 'config.h'.
* lang/python/helpers.c: Likewise.
* lang/python/helpers.h: Likewise.
* lang/python/setup.py.in: Make sure that 'config.h' can be found.
--
Fixes build on 32 bit platforms with large file support.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-26 16:54:57 +02:00
Werner Koch
936928632b
python: Create install dir.
* lang/python/Makefile.am (install-exec-local): Create dir.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-21 09:18:00 +02:00
Werner Koch
0763357e39
tests: Make "make -j distcheck" work in Python.
* lang/python/Makefile.am (SUBDIRS): Make current dir fist.
* lang/python/tests/Makefile.am (xcheck): Depend on pubring-stamp.
(CLEANFILES): Remove private-keys-v1.d/gpg-sample.stamp.
(check-local): Remove.
(initial.py): Remove dependency.
(./pubring-stamp): Depend on conf files and the
private-keys-v1.d/gpg-sample.stamp file.  Also replace use of
basename.

--

This addresses the problem that two rules might run the private keys
copy rule and due to the files being chmod -w during make discheck the
second process running that rule's cp would get a permission error.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-20 19:58:00 +02:00
Werner Koch
bfb6890ded
tests: Use --batch for gpg import.
* lang/python/tests/Makefile.am (./pubring-stamp): Use --batch with
GPG to avoid Pinentries during import when using GnuPG >= 2.1.
Replace touch by echo.
* tests/gpg/Makefile.am (./pubring-stamp): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-20 19:51:02 +02:00
Werner Koch
29207bcd3b
tests: Improve portability.
* lang/qt/tests/Makefile.am (clean-local): Avoid non-portable "--"
* lang/python/Makefile.am (copystamp): Use well defined cp -R instead
of cp -r.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-20 19:46:04 +02:00
Justus Winter
65f6f68f09 python: Improve metadata and READMEs.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-19 12:49:14 +02:00
Werner Koch
b615316168
core: Document the version a function has been deprecated.
* src/gpgme.h.in (_GPGME_DEPRECATED): Change to take versio numbers
for documentation.  Change all places.
(_GPGME_DEPRECATED_OUTSIDE_GPGME): Ditto.
* lang/python/gpgme-h-clean.py: Adjust RE.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-16 16:00:27 +02:00
Justus Winter
6af7bee076 python: Release the GIL during calls into GPGME.
* lang/python/helpers.c (pyme_raise_callback_exception): Re-acquire
the Global Interpreter Lock.
(pyPassphraseCb, pyme_set_passphrase_cb, pyProgressCb,
pyme_set_progress_cb, pyStatusCb, pyme_set_status_cb,
_pyme_interact_cb, pyDataReadCb, pyDataWriteCb, pyDataSeekCb,
pyDataReleaseCb, pyme_data_new_from_cbs, _pyme_assuan_data_cb,
_pyme_assuan_inquire_cb, _pyme_assuan_status_cb): Likewise.
* lang/python/setup.py.in: Make 'gpgme-config' emit the correct
cflags, and SWIG generate code to release the GIL before calling us.

Co-authored-by: Kai Michaelis <kai@gnupg.org>
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-16 15:56:47 +02:00
Justus Winter
a458e7fe20 python: Adapt to 'gpgme_op_interact'.
* lang/python/examples/inter-edit.py: Update example.
* lang/python/gpgme.i (gpgme_edit_cb_t): Turn into
'gpgme_interact_cb_t'.
* lang/python/helpers.c (_pyme_edit_cb): Turn into
'_pyme_interact_cb_t'.
* lang/python/private.h (_pyme_edit_cb): Likewise.
* lang/python/pyme/constants/__init__.py: Replace numeric status codes
with the keywords.
* lang/python/pyme/constants/status.py: Likewise.
* lang/python/pyme/core.py (Context.interact): New method.
(Context.op_edit): Deprecate, update docstring, implement using
Context.interact.
* lang/python/tests/t-edit.py: Test both interfaces.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-16 14:56:29 +02:00
Justus Winter
594c3b8b05 python: Clarify that we support Python 2.7 too.
* lang/python/README: Use 'Python' instead of 'Python 3'.
* lang/python/pyme/version.py.in: Likewise.
* lang/python/setup.py.in: Add classifier for 2.7, drop 3 only.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 14:36:29 +02:00
Justus Winter
4011b2b2a1 python: Trim imports.
* lang/python/examples/encrypt-to-all.py: Drop unused import of 'os'.
* lang/python/examples/signverify.py: Likewise.
* lang/python/examples/simple.py: Likewise.
* lang/python/examples/verifydetails.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 14:35:00 +02:00
Justus Winter
44d18200d5 python: Improve error handling.
* lang/python/gpgme.i (gpgme_engine_info_t): Improve error handling.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 14:34:14 +02:00
Justus Winter
f6cd560ca7 python: Adapt to TOFU changes.
* lang/python/pyme/results.py (TofuInfo): Drop.
(Signature): The TOFU information moved to the key.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 14:32:48 +02:00
Justus Winter
24b4162d90 python: Build for both Python2 and Python3.
* NEWS: Update.
* configure.ac: Check for multiple Python versions.
* lang/python/Makefile.am: Build and install for both Python versions.
* lang/python/tests/Makefile.am: Test both versions.
* lang/python/tests/run-tests.py: New test runner.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 12:18:15 +02:00
Justus Winter
dc23fdf555 python: Import from __future__ to align behavior of Python 2.7.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 12:15:57 +02:00
Justus Winter
3b37c4efcf python: Use more generic shebang.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 12:15:57 +02:00
Justus Winter
70a3be27a5 python: Handle slight differences between Python 2 and 3.
* lang/python/helpers.c (pyDataWriteCb): Handle Python integers being
returned on Python 2.
(pyDataSeekCb): Likewise.
* lang/python/pyme/core.py (Data.__init__): Fix testing for string
argument.
(Data.new_from_filepart): Likewise.
* lang/python/pyme/util.py (is_a_string): New function.
* lang/python/tests/t-encrypt-large.py (read_cb): Force evaluation of
generator.
* lang/python/tests/t-idiomatic.py: Partly skip test on Python 2.
* lang/python/tests/t-verify.py (check_result): Here, the difference
between 2 and 3 really matters.  We cannot change the char *
conversion in Python 2 without breaking all existing applications, and
using bytestrings in Python 3 would be very inconvenient.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-13 13:29:43 +02:00
Justus Winter
4abff7d750 python: Fix types and error handling.
* lang/python/helpers.c (_pyme_edit_cb): Drop the const.
(_pyme_assuan_{data,inquire,status}_cb): Fix error handling.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-13 13:29:43 +02:00
Justus Winter
c0c50318bd python: Avoid Python3-only form of super().
* lang/python/pyme/core.py (GpgmeWrapper.__repr__): Use more
compatible form of super.
(GpgmeWrapper.__setattr__): Likewise.
(Context.__init__): Likewise.
(Data.__init__): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 17:24:18 +02:00
Justus Winter
1d5bbbf118 python: Make type translation compatible with Python 2.7.
* lang/python/gpgme.i: Avoid functions not available in Python 2.7.
* lang/python/helpers.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 17:11:19 +02:00
Justus Winter
70999d8161 python: Avoid hardcoding the interpreter.
* lang/python/setup.py.in: Avoid hardcoding the interpreter.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 16:19:07 +02:00
Justus Winter
b48b852a84 python: Do not rely on subprocess.DEVNULL.
* lang/python/setup.py.in: Do not rely on subprocess.DEVNULL.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 16:18:31 +02:00
Justus Winter
a0263ad282 tests: Make signature notation test compatible with older GnuPGs.
* lang/python/tests/t-sig-notation.py: Only check the critical flag
when GnuPG >= 2.1.13 is used.
* tests/gpg/t-sig-notation.c: Likewise.

Fixes-commit: c88c9ef3
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 14:56:07 +02:00
Andre Heinecke
ab6f66d676 Prepend LD_LIBRARY_PATH for python tests
* lang/python/tests/Makefile.am (TESTS_ENVIRONMENT): Prepend path
instead of setting the value.

--
This fixes the case where tools / libararies are needed for
a working GnuPG system that are pointed to by LD_LIBRARY_PATH.
E.g. GnuPG itself is installed in a custom prefix and PATH /
LD_LIBRARY_PATH is set accordingly.
2016-08-08 15:04:01 +02:00
Justus Winter
2a613e8715 python: Clean up and modernize examples.
* lang/python/examples/Examples.rst: Delete file.
* lang/python/examples/t-edit.py: Likewise.  This is actually a test
case and has been moved to 'tests'.
* lang/python/examples/assuan.py: New file.
* lang/python/examples/decryption-filter.py: Likewise.
* lang/python/examples/delkey.py: Modernize.
* lang/python/examples/encrypt-to-all.py: Likewise.
* lang/python/examples/exportimport.py: Likewise.
* lang/python/examples/genkey.py: Likewise.
* lang/python/examples/inter-edit.py: Likewise.
* lang/python/examples/sign.py: Likewise.
* lang/python/examples/signverify.py: Likewise.
* lang/python/examples/simple.py: Likewise.
* lang/python/examples/testCMSgetkey.py: Likewise.
* lang/python/examples/verifydetails.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-05 14:05:49 +02:00
Justus Winter
56e26b54da python: Add a nicer interface to list keys.
* lang/python/pyme/core.py (Context.keylist): New method.
* lang/python/tests/t-keylist.py: Test new method.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-03 16:32:30 +02:00
Justus Winter
4c8265d32d python: Add a flag identifying in-tree builds.
* lang/python/helpers.c (pyme_in_tree_build): New variable.
* lang/python/helpers.h (pyme_in_tree_build): New declaration.
* lang/python/pyme/version.py.in (in_tree_build): New variable.
* lang/python/setup.py.in: Rework macro handling, set 'IN_TREE_BUILD'
as appropriate.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-02 18:45:10 +02:00
Justus Winter
0bd7d8c197 python: Fix build system integration.
* lang/python/Makefile.am: Be more careful when cleaning the build
directory, we must not delete the generated file 'pyme/version.py'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-02 18:42:26 +02:00
Justus Winter
4e728de842 python: Fix out-of-tree build.
* lang/python/MANIFEST.in: Add 'private.h'.

Fixes-commit: 3d4dc3f0
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 18:14:08 +02:00
Justus Winter
5a7c7a86f7 python: Improve error handling.
* lang/python/pyme/core.py (Context.protocol): Check that the engine
is usable before setting the protocol.
(Context._errorcheck): Add missing functions.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 17:50:07 +02:00
Justus Winter
2ff58fcbd5 python: Drop superfluous imports and trim public interface.
* lang/python/pyme/__init__.py: Avoid leaking low-level 'gpgme', make
sure the main module looks nice and tidy, appease pyflakes.
* lang/python/pyme/errors.py: Appease pyflakes.
* lang/python/pyme/util.py: Avoid leaking low-level 'gpgme' into the
module namespace.
* lang/python/pyme/version.py.in: Likewise.
* lang/python/tests/t-keylist.py: Drop superfluous imports.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-sign.py: Likewise.
* lang/python/tests/t-signers.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 16:50:02 +02:00
Justus Winter
2f754440f2 python: Rename compiled SWIG module.
Avoid the name pygpgme, as this is the name of another popular Python
binding for GPGME.

This commit renames the compiled Python module produced by SWIG.

* lang/python/Makefile.am: Rename the compiled Python module.
* lang/python/gpgme.i: Likewise.
* lang/python/pyme/core.py: Likewise.
* lang/python/pyme/errors.py: Likewise.
* lang/python/pyme/util.py: Likewise.
* lang/python/pyme/version.py.in: Likewise.
* lang/python/setup.py.in: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 16:49:50 +02:00
Justus Winter
b5aa05c3b2 python: Rename exported functions.
Avoid the name pygpgme, as this is the name of another popular Python
binding for GPGME.

This commit renames all functions that are exported to the Python
world.

* lang/python/helpers.c: Rename all exported functions.
* lang/python/helpers.h: Likewise.
* lang/python/pyme/core.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 15:26:43 +02:00
Justus Winter
1d2f22aae6 python: Rename private functions.
Avoid the name pygpgme, as this is the name of another popular Python
binding for GPGME.

This commit renames all functions that are not exported to the Python
world.

* lang/python/gpgme.i: Rename all private functions.
* lang/python/helpers.c: Likewise.
* lang/python/helpers.h: Likewise.
* lang/python/private.h: Likewise.  Also move the SWIG runtime helper
prototypes here.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 15:26:43 +02:00
Justus Winter
de69fa496c python: Support the Assuan engine.
* lang/python/gpgme.i: Add typemaps for the Assuan protocol callbacks.
* lang/python/helpers.c (_pyme_assuan_{data,inquire,status}_cb): New
functions.
* lang/python/private.h (_pyme_assuan_{data,inquire,status}_cb): New
prototypes.
* lang/python/pyme/core.py (Context.assuan_transact): New method.
* lang/python/pyme/util.py (percent_escape): New function.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/t-protocol-assuan.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 14:23:07 +02:00
Justus Winter
355d707286 python: Improve engine information handling.
* lang/python/gpgme.i (gpgme_engine_info_t): Wrap engine infos.
* lang/python/pyme/core.py (Context.engine_info): New property.
(Context.{g,s}et_engine_info): Improve docstrings.
* lang/python/pyme/results.py (EngineInfo): New class.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 11:16:35 +02:00
Justus Winter
78f7bf4dcf python: Add accessors for the protocol.
* lang/python/pyme/core.py (Context.__init__): Add 'protocol'
parameter.
(Context.protocol): New accessors.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 10:59:46 +02:00
Justus Winter
3d4dc3f021 python: Expose less functions to the Python world.
* lang/python/Makefile.am (EXTRA_DIST, COPY_FILES): Add new file.
* lang/python/gpgme.i: Include new file and add comments.
* lang/python/helpers.c: Include new file.
* lang/python/helpers.h: Move functions we do not need to expose...
* lang/python/private.h: ... here.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 10:23:32 +02:00
Justus Winter
e545ca3f68 python: Make GPGME's version easily accessible.
* lang/python/pyme/version.py.in (gpgme_versionstr): New variable.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-15 18:28:19 +02:00
Justus Winter
1f318b7aaa python: Add an idiomatic interface.
* configure.ac: Bump required Python version.
* lang/python/pyme/__init__.py: Update docstring.  Import Context and
Data.
* lang/python/pyme/core.py (Context.encrypt): New function.
(Context.decrypt): Likewise.
(Context.sign): Likewise.
(Context.verify): Likewise.
* lang/python/pyme/errors.py: Add new errors.
* lang/python/pyme/util.py (process_constants): Rework and return the
inserted keys.
* lang/python/tests/Makefile.am (EXTRA_DIST): Add new keys.
* lang/python/tests/encrypt-only.asc: New file.
* lang/python/tests/sign-only.asc: Likewise.
* lang/python/tests/initial.py: Mark key 'Alpha' as trusted, import
new keys.
* lang/python/tests/support.py: Add fingerprints of known keys.
(in_srcdir): New function.
(print_data): Handle bytes too.
(mark_key_trusted): New function.
* lang/python/tests/t-decrypt-verify.py: Adjust test.  Test idiomatic
interface.
* lang/python/tests/t-decrypt.py: Test idiomatic interface.
* lang/python/tests/t-encrypt-sign.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-encrypt.py: Likewise.
* lang/python/tests/t-idiomatic.py: Simplify.
* lang/python/tests/t-keylist.py: Adjust to newly trusted key.
* lang/python/tests/t-sign.py: Likewise.  Test idiomatic interface.
* lang/python/tests/t-signers.py: Likewise.
* lang/python/tests/t-verify.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-15 18:28:09 +02:00
Justus Winter
fddcc62abd python: Fix test.
* lang/python/tests/t-keylist.py: Do not assume key alpha is trusted
yet.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-14 13:34:49 +02:00
Justus Winter
b68700d227 python: Drop bad category.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-14 13:34:49 +02:00
Justus Winter
1bff47ee58 python: Port more tests.
* lang/python/pyme/core.py (Context.op_keylist_all): Add missing
'op_keylist_end'.
(Context.op_trustlist_all): Fix function. Add missing
'op_trustlist_end'.
* lang/python/tests/Makefile.am (pytests): Add new files.
* lang/python/tests/t-import.py: New file.
* lang/python/tests/t-keylist.py: Likewise.
* lang/python/tests/t-trustlist.py: Check alternate interface.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-12 18:34:12 +02:00
Justus Winter
57b5168552 python: Improve python packaging.
* lang/python/Makefile.am: Sign source releases, and upload them.
* lang/python/setup.py.in: Add categories.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-12 18:34:12 +02:00
Justus Winter
ce66289137 python: Fix distcheck.
* lang/python/Makefile.am (EXTRA_DIST): Add missing files.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-11 19:42:56 +02:00
Justus Winter
007382ce94 python: Enable out-of-tree build of pyme bindings.
* lang/python/MANIFEST.in: Update manifest template.
* lang/python/Makefile.am: Copy more files, move generation of files
to Python build script, add 'sdist' target to build a Python source
distribution.
* lang/python/gpgme-h-clean.py: Add code to build 'errors.i'.
* lang/python/setup.py.in: Generate files, enable out-of-tree builds.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-11 18:09:54 +02:00
Justus Winter
98cba522c9 python: Do not depend on access to internal data structures.
* lang/python/gpgme.i (gpgme_data_t): Rework so that it works without
access to the definition of 'struct gpgme_data'.
* lang/python/helpers.c (object_to_gpgme_data_t): Add assertion.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-11 17:50:58 +02:00
Justus Winter
c53f87c5f9 python: Make result wrapping backwards compatible.
* lang/python/pyme/results.py (Result.__init__): Skip missing fields.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-11 17:50:58 +02:00
Justus Winter
8a93f345b7 python: Fix raising stashed exceptions.
Fixes an issue with newer versions of Python.

* lang/python/helpers.c (pygpgme_raise_callback_exception): Be more
careful when restoring the exception.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-08 11:45:08 +02:00
Justus Winter
52efcf1ee9 python: Fix distcheck.
* lang/python/INSTALL: Drop obsolete file.
* lang/python/Makefile.am (EXTRA_DIST): Add missing files.
(CLEANFILES): Remove generated files.
(clean-local): Fix permissions of copied files.
* lang/python/tests/Makefile.am (TESTS): Use our own setup and
teardown scripts.
(EXTRA_DIST): Add missing files.
* lang/python/tests/final.py: New file.
* lang/python/tests/initial.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-07 14:10:36 +02:00
Justus Winter
8997d88bf9 python: Improve autmatically generated docstrings.
* lang/python/gpgme.i: Add comment.
* lang/python/pyme/core.py (__getattr__): Rewrite automatically
generated doctrings for the wrapper methods.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:19:17 +02:00
Justus Winter
a324d0cffe python: Make result objects more robust.
Results returned by the GPGME are fragile, i.e. they are only valid
until the next operation is performed in the context.

We cannot arbitrarily constrain the lifetime of Python objects, we
therefore create deep copies of the results.

* lang/python/gpgme.i (gpgme_tofu_info_t): Turn these into a list.
(gpgme_*_result_t): Create deep copies of these objects.
* lang/python/helpers.c (pygpgme_wrap_fragile_result): New function.
* lang/python/helpers.h (pygpgme_wrap_fragile_result): New prototype.
* lang/python/pyme/results.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:19:17 +02:00
Justus Winter
856bcfe293 python: Avoid creating SWIG proxy classes.
* lang/python/Makefile.am (gpgme_wrap.c): Use '-builtin' to make SWIG
generate builtin types for c types.
* lang/python/gpgme.i (pygpgme_wrap_gpgme_data_t): Adapt slightly.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:19:17 +02:00
Justus Winter
6641c7814b python: Simplify wrapping glue.
* lang/python/pyme/core.py: Rename '_getctype' to '_ctype' and turn it
  into a string.  Likewise rename '_getnameprepend' to '_cprefix'.
* lang/python/helpers.c: Adapt accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:19:17 +02:00
Justus Winter
f3618bc615 python: Rework callbacks.
Simplify how the lifetime of callback arguments is managed.

* lang/python/gpgme.i (gpgme_edit_cb_t): Check arguments.
(PyObject_p_p, void_p_p): Drop rather dangerous interface.
(pygpgme_unwrap_gpgme_ctx_t): New function.
* lang/python/helpers.c (pygpgme_clear_generic_cb): Drop dangerous
function.
(pyPassphraseCb): Assert contract.
(pygpgme_set_passphrase_cb): Use Python's calling convention so that
we can raise exceptions.  Hand in 'self', get the wrapped object, and
simply store the hook data as attribute of the wrapper object.
(pyProgressCb, pygpgme_set_progress_cb): Likewise.
(pygpgme_set_status_cb): Likewise.
(pygpgme_data_new_from_cbs): Likewise.
* lang/python/helpers.h (pygpgme_clear_generic_cb): Drop prototype.
(pygpgme_set_passphrase_cb): Update prototype.
(pygpgme_set_progress_cb): Likewise.
(pygpgme_set_status_cb): Likewise.
(pygpgme_data_new_from_cbs): Likewise.
(pygpgme_unwrap_gpgme_ctx_t): New prottotype.
* lang/python/pyme/core.py (Context, Data): Update callsites.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:19:17 +02:00
Justus Winter
616929b6ed python: Wrap objects implementing the buffer protocol.
* lang/python/Makefile.am: Add the toplevel source directory to CFLAGS
when compiling the bindings so that we can use private header files.
* lang/python/gpgme.i (gpgme_data_t): Rework the object wrapping.  Do
not create a Python wrapper object, merely a gpgme_data_t object, and
keep references to buffer objects, if any.  If necessary, update the
buffer after the function call.
(pygpgme_wrap_gpgme_data_t): New function.
* lang/python/helpers.c (object_to_gpgme_data_t): Rework object
wrapping.  Also wrap objects implementing the buffer protocol.
* lang/python/helpers.h (object_to_gpgme_data_t): Update prototype.
(pygpgme_wrap_gpgme_data_t): New prototype.
* lang/python/tests/t-idiomatic.py: Demonstrate this.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:19:17 +02:00
Justus Winter
5464060bae python: Add properties to wrapped object.
* lang/python/pyme/core.py (GpgmeWrapper.__repr__): Saner
representation.
(GpgmeWrapper.__str__): Construct a nicer human readable string.
(GpgmeWrapper._boolean_properties): New field.
(GpgmeWrapper.__wrap_boolean_property): New function.
(GpgmeWrapper.__getattr__): Wrap functions using properties.
(GpgmeWrapper.__setattr__): New method.  Likewise wrap functions.
(Context.signers): New property.
(Context.pinentry_mode): Likewise.
(Context._boolean_properties): List boolean properties.
(Context.__init__): Add keyword arguments for properties and apply
them.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:19:17 +02:00
Justus Winter
5492853d7b python: Improve the documentation.
* lang/python/Makefile.am: Copy the README file.
* lang/python/README: Rename, convert to org, and update.
* lang/python/pyme/__init__.py: Move license out of the docstring,
update docstring.
* lang/python/pyme/core.py: Add and update docstrings.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:07:41 +02:00
Justus Winter
7eef399d89 python: Get version information from the build system.
* configure.ac: Generate 'setup.py' and 'version.py'.
* lang/python/Makefile.am: Use generated setup script.
* lang/python/pyme/version.py: Turn it into a template, and get
version information from the build system.  Also drop some variables.
* lang/python/setup.py: Likewise.  This way we can avoid importing the
version module, which is frowned upon and actually caused a problem.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:07:41 +02:00
Justus Winter
a852f99a0a python: Fix exception leak.
* lang/python/helpers.c (pygpgme_stash_callback_exception): Fix leak.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:07:41 +02:00
Justus Winter
3bacce03e6 python: Fix license.
Other parts of the build system are also LGPLed.

* lang/python/Makefile.am: Fix license.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:07:41 +02:00
Justus Winter
77d149e861 python: Improve error handling.
* lang/python/helpers.c (pyPassphraseCb): Handle write errors.
(pyEditCb): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-08 18:12:35 +02:00
Justus Winter
5ebc205439 python: Add function to raise exceptions from c.
* lang/python/helpers.c (pygpgme_raise_exception): New function.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-08 17:54:45 +02:00
Justus Winter
8426304b67 python: Fix stripping deprecated functionality.
* lang/python/Makefile.am (gpgme.h): Add script as input.
* lang/python/gpgme-h-clean.py (deprec_func): Also match struct
members.
(line_break): Fix matching on struct members.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-08 17:12:00 +02:00
Justus Winter
990492ea4f python: Fix type.
* lang/python/gpgme.i: Use correct Python type for size.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-08 17:12:00 +02:00
Justus Winter
e3c5913a33 python: Implement the context manager protocol.
* lang/python/pyme/core.py (Context.__del__): Make function
idemptotent.
(Context.{__enter__,__exit__}): Implement the context manager
protocol.
(Data.__del__): Make function idemptotent, drop debug print.
(Data.{__enter__,__exit__}): Implement the context manager
protocol.
* lang/python/tests/t-idiomatic.py: Demonstrate this.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-08 13:44:09 +02:00
Justus Winter
f8f9bf06bc python: Fix error handling.
* lang/python/gpgme.i: Fix freeing an uninitialized pointer in the
error handling of generated wrapper functions by explicitly storing
the pointer in a local variable which can be initialized.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-07 19:34:51 +02:00
Justus Winter
8196edf9ca python: Wrap file-like objects on demand.
* lang/python/gpgme.i (gpgme_data_t): Use new function to create
wrapper objects if necessary, and deallocate them after the function
call.
* lang/python/helpers.c (object_to_gpgme_data_t): New function.
* lang/python/helpers.h (object_to_gpgme_data_t): New prototype.
* lang/python/tests/Makefile.am (pytests): Add new test.
* lang/python/tests/t-idiomatic.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-06 14:16:04 +02:00
Justus Winter
26c3accc95 python: Move helper function.
* lang/python/gpgme.i (object_to_gpgme_t): Move...
* lang/python/helpers.c: ... here.
* lang/python/helpers.h (object_to_gpgme_t): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-06 14:16:04 +02:00
Justus Winter
89eb0cd4d6 python: Fix error handling.
* lang/python/gpgme.i (object_to_gpgme_t): Properly propagate
exceptions.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-06 14:16:04 +02:00
Justus Winter
ae06f7c2fe python: Initialize GPGME for the user.
* lang/python/pyme/core.py: Call 'check_version' and explain why.
* lang/python/tests/support.py (init_gpgme): Drop call here.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-06 14:16:04 +02:00
Justus Winter
2055a63605 python: Drop obsolete VCS keywords.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-06 14:16:01 +02:00
Justus Winter
bbf19124bb python: Fix test suite with GnuPG prior to 2.1.12.
* lang/python/tests/Makefile.am (gpg-agent.conf): Use
'allow-loopback-pinentry'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-01 15:40:49 +02:00
Justus Winter
73c47535b6 python: Improve build system integration, fix warnings.
* lang/python/Makefile.am: Pass CFLAGS to python build system.
* lang/python/helpers.c (pyPassphraseCb): Use correct type for length.
(pygpgme_data_new_from_cbs): Drop unused variable.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-01 14:18:45 +02:00
Justus Winter
c88c9ef384 tests: Fix notation tests.
* lang/python/tests/t-sig-notation.py (check_result): Check critical
flag.
* tests/gpg/t-sig-notation.c (check_result): Likewise.

Fixes-commit: 1cacd7d0
Signed-off-by: Justus Winter <justus@gnupg.org>
2016-06-01 12:50:32 +02:00
Tobias Mueller
8ad17f402f python: use GPG_ERROR_CONFIG variable
instead of calling gpg-error-config.
This is useful when configuring with --with-gpgerror-prefix
because then GPG_ERROR_CONFIG contains the correct
/path/to/bin/gpg-error-config whereas calling gpg-error-config
directly would look in the user's PATH (and not in the prefix
where gpg-error-config was installed).

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-31 16:35:59 +02:00
Justus Winter
afa0dd56e1 python: Port more tests.
* lang/python/gpgme.i: Hide length fields of notations.
* lang/python/tests/Makefile.am (pytests): Add new tests.
* lang/python/tests/t-decrypt-verify.py: New file.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-verify.py: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-31 16:22:31 +02:00
Justus Winter
3915842657 python: Port more tests.
* lang/python/pyme/core.py (Data._error_check): Add
'gpgme_data_get_file_name' to the list of functions not returning an
error code.
* lang/python/tests/Makefile.am (pytests): Add new tests.
* lang/python/tests/support.py (verbose): New variable.
* lang/python/tests/t-data.py: Test setting and getting the filename.
* lang/python/tests/t-encrypt-large.py: New file.
* lang/python/tests/t-file-name.py: Likewise.
* lang/python/tests/t-trustlist.py: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-27 17:24:12 +02:00
Justus Winter
2ae847c027 python: Implement data callbacks.
* lang/python/gpgme.i (object_to_gpgme_t): Set exception on error.
* lang/python/helpers.c (pyDataReadCb): New function.
(pyDataWriteCb): Likewise.
(pyDataSeekCb): Likewise.
(pyDataReleaseCb): Likewise.
(pygpgme_data_new_from_cbs): Likewise.
* lang/python/helpers.h (pygpgme_data_new_from_cbs): New prototype.
* lang/python/pyme/core.py (Data.__init__): Fix docstring, fix read
callbacks.
(Data.__del__): Fix read callbacks.
(Data._free_readcb): Drop function.
(Data._free_datacbs): New function.
(Data.new_from_cbs): Fix setting the callbacks.
(Data.write): Raise stashed exceptions.
(Data.read): Likewise.
* lang/python/tests/t-callbacks.py: Test new functionality.
* lang/python/tests/t-data.py: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-27 14:04:28 +02:00
Justus Winter
ebfe2300c3 python: Fix object deallocation.
Handing a reference to the wrapper object created a non-trivial
circular reference that Pythons garbage collector is unable to break.
Explicitly break it by using a weak reference.

* lang/python/helpers.c (pygpgme_stash_callback_exception): Retrieve
object from weak reference.
* lang/python/pyme/core.py (Context.__del__): Free status callback.
(Context.set_passphrase_cb): Use a weak reference.
(Context.set_progress_cb): Likewise.
(Context.set_status_cb): Likewise.
(Context.op_edit): Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-27 12:25:59 +02:00
Justus Winter
bf188e280b python: Fix reading data from existing files.
* lang/python/pyme/core.py (Data.__init__): Add 'copy' kwargument, and
pass it to functions supporting it.  PEP8 fix.
(Data.new_from_fd): PEP8 fix.
(Data.new_from_file): Give a more helpful error message if copy is
False.  PEP8 fix.
(Data.new_from_fd): Hand the file descriptor to
'gpgme_data_new_from_fd', not a stream.  Fix docstring.
* lang/python/tests/t-data.py: Add tests for this.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-27 12:18:29 +02:00
Justus Winter
00ff6d0733 python: Improve and test Context.wait.
* lang/python/pyme/core.py (Context.wait): Improve docstring.  As the
context passed to 'gpgme_wait' is never NULL, it is pointless to look
at the returned context.  Always raise exceptions.
* lang/python/tests/Makefile.am (pytests): Add new test.
* lang/python/tests/t-wait.py: New file.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-24 18:00:16 +02:00
Justus Winter
7bc9cc717e python: Make all GnuPG errors available.
* lang/python/Makefile.am (errors.i): Generate file.
* lang/python/gpgme.i: Include generated file.
* lang/python/pyme/errors.py: Pull in all errors and error sources.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-24 18:00:16 +02:00