Commit Graph

572 Commits (a34084c33239e96f0d29583c3db65c296181b27c)

Author SHA1 Message Date
Isis Lovecruft 81312015ab
Remove everything except the GPG class from src/__init__.py. 2013-05-17 02:38:25 +00:00
Isis Lovecruft 891ee9e7eb
Significantly improve logging facilities for faster debugging.
* Include _ansistrm.py, which was released under new BSD license separately in
   a github gist as well as in the Python logutils module. Instead of setting
   up a src/includes/ directory, I have included this file in the currently
   flat module directory, because dealing with submodule imports in Python2.x
   is a pain. I'm not sure if this will cause problems for Debian packaging,
   but it could be changed later if so. The full text of the original license
   and copyright has been retained at the head of _ansistrm.py, clearly
   demarcated from python-gnupg's license and copyright info. The author of
   _ansistrm.py is the same as the current upstream maintainer for
   python-gnupg, Vinay Sajip, and I don't see why this person doesn't include
   _ansistrm.py in all of their packages, because it is making skimming the
   test logs for errors much faster.

 * Add _logger.py, which contains a class decorator:

       @wraps(logging.Logger)
       def create_logger(level=logging.NOTSET)
       [...]

   which autoconfigures logging functionality. By default, logging.NullHandler
   is still used, so there are no logs (neither logfiles nor piped to
   stdout). If _logger.create_logger() is called with either a LEVEL attribute
   from the logging module, or the integer equivalent, it will initialise
   logging to stdout only. In the unittest suite, extra log handling
   functionality is added to also write to a datetime-stamped logfile in the
   tests/ directory.

 * Change all "logger.<level>" statements to "log.<level>" and add new ones for
   debugging and user information purposes.

 * Remove the import of the python standard utilities logging module from:
       src/gnupg.py
       src/parsers.py
       src/util.py

   and switch to setting a top-level attribute, util.log, which is the returned
   class from _logger.create_logger(). Everything else now does "from util
   import log".
2013-05-17 02:15:17 +00:00
Isis Lovecruft 3038e3948b
Remove relative imports of every class in parsers.py, they crowd the namespace. 2013-05-17 01:13:02 +00:00
Isis Lovecruft 5fe8320fd0
We don't need module strings with a flat directory structure. 2013-05-17 01:08:07 +00:00
Isis Lovecruft 2686131809
Reorder frozenset of allowed options so that it's easier to read. 2013-05-17 01:04:45 +00:00
Isis Lovecruft b84268fecd
Locally scoped ivars in _check_preferences don't need private namespace. 2013-05-17 01:02:27 +00:00
Isis Lovecruft 615e2cfa60
Add docstring for parsers._check_preferences. 2013-05-17 01:00:05 +00:00
Isis Lovecruft 81514e0ec4
Fix parsers._check_preferences function to use set theoretic intersection.
* It benchmarks super fast. And I get to use set theory.
2013-05-17 00:58:43 +00:00
Isis Lovecruft 41d9ab27bd
Don't point users to github, where possible.
* Github has these rather nasty tracking mechanisms through pixel cookies, as
   well as hardware fingerprinting (potentially deanonymising) through HTML5
   canvases.
 * I suck at configuring gitweb + lighttpd. I cannot get pretty URLs for the
   repos, but it's still better than the pixel cookies. If anyone can point me
   at something for fixing this, much obliged. I wasn't sure if I should point
   explicitly to a LEAP server.
2013-05-17 00:54:48 +00:00
Isis Lovecruft 26da5c3e73
Remove copyright info from top level of module.
* Previously, it was:
       In [1]: import gnupg
       In [2]: gnupg.
       gnupg.GPG       gnupg.copyright  gnupg.logger    gnupg.util
       gnupg.copyleft  gnupg.gnupg      gnupg.parsers
   So I've started cleaning up the API so the only thing visible on module import
   is the class you probably need: gnupg.GPG .
2013-05-17 00:45:59 +00:00
Isis Lovecruft a9154b25d5
Add .gitattributes file for versioneer. 2013-05-13 10:16:39 +00:00
Isis Lovecruft 1588822f02
Fix accidental misnaming from sed 's/pubring/keyring/'. 2013-05-13 09:14:42 +00:00
Isis Lovecruft e462cf42ed
Call parsers._check_preferences() to set default_preference_list. 2013-05-13 02:39:19 +00:00
Isis Lovecruft c5a7ccb572
Update module level docstring. 2013-05-13 00:46:58 +00:00
Isis Lovecruft 0fa269c93c
Fix the directory shortcuts in utils.py according to the new module layout. 2013-05-13 00:44:29 +00:00
Isis Lovecruft c305f8c5c3
Add tests to Makefile cmds, and add better test cleanup. 2013-05-12 10:22:44 +00:00
Isis Lovecruft c97b51fec5
Add versioneer and restructure the repo into a src/ dir. 2013-05-12 09:32:46 +00:00
Isis Lovecruft 25637ef50e
PEP-8ify a couple lines that were running off the screen.
* Also, change a logger string to say 'GnuPG' instead of the binary's name
   'gpg'.
2013-05-11 18:34:28 +00:00
Isis Lovecruft e3eb7eea0c
Fix an old-style class. 2013-05-11 18:33:39 +00:00
Isis Lovecruft 2700b3c338
Return the result of a encryption or decryption operation without *.data 2013-05-11 18:32:18 +00:00
Isis Lovecruft e5ac938486
Add hastily written check_preferences().
* TODO I sleepily realised two lines before the end of bashing this out that
   it should just be a set difference.
2013-05-11 18:30:22 +00:00
Isis Lovecruft 4258900368
Fix a bug which caused result_map['crypt'] to expect a Verify(). 2013-05-11 18:28:47 +00:00
Isis Lovecruft 0785d7dd3b
Various docstring and whitespace fixes in parsers.py. 2013-05-11 18:28:04 +00:00
Isis Lovecruft cc7beb7185
Rewrite GPG.decrypt_file(). 2013-05-11 18:26:14 +00:00
Isis Lovecruft cfd7b38242
Add option to delete subkeys with GPG.delete_keys().
* TODO this needs unittests.
2013-05-11 18:25:17 +00:00
Isis Lovecruft ae0ab0a7c7
WHO PUTS UNITTESTS IN A TRY/EXCEPT BLOCK WHICH CATCHES ALL EXCEPTIONS?!
* WHAT WAS THE POINT OF WRITING THE UNITTEST IF IT ALWAYS PASSES?
2013-05-11 18:22:50 +00:00
Isis Lovecruft 347cecb9f2
Add unittests for multiparty file en/decryption and symmetric en/decryption. 2013-05-11 18:22:07 +00:00
Isis Lovecruft 23b3315c45
Remove old logger statements and comments. 2013-05-11 18:20:49 +00:00
Isis Lovecruft b76bf502c9
Add better unittests for homedir and keyring creation. 2013-05-11 18:19:59 +00:00
Isis Lovecruft f06c2d7396
Cleanup docstring for GPGTestCase.setUpClass(). 2013-05-11 18:19:04 +00:00
Isis Lovecruft 2a92e3f10b
Since we use '--no-emit-version', we don't need this anymore. 2013-05-11 18:18:18 +00:00
Isis Lovecruft d38efaffbc
Use proper tempfile isolation of GnuPG homedirs in unittests. 2013-05-11 18:17:22 +00:00
Isis Lovecruft 14ffe14569
Add a unittest and a fix for hexidecimal inputs with lowercase. 2013-05-11 18:16:18 +00:00
Isis Lovecruft dce4b4a226
Rename handle_status() parser methods to be private to cleanup the API. 2013-05-11 18:10:41 +00:00
Isis Lovecruft 38057cfe1c
Add various new options and assign input parsers to them. 2013-05-11 18:09:33 +00:00
Isis Lovecruft e4f2d533b1
Add cipher, compress, and digest preferences and rename parameters.
* Rename gpghome to homedir.
 * Rename gpgbinary to binary.
 * Add setting to append '--no-use-agent' to the command string in an attempt
   to overcome bugs resulting on systems where the user has gpg-agent running
   in the background (with some configurations, this is run before X is
   started, and killing the agent can result in X dying) and GnuPG tries to
   call the program specified by the symlink at /usr/bin/pinentry, result in
   encryption and decryption failing due to the '--batch' option blasting
   through pinentry without input. This results in a complaint from GnuPG:

       gpg: Sorry, no terminal at all requested - can't get input

   This bug also prevents symmetric encryption/decryption from working in a
   similar manner.
       Daniel Kahn Gilmor's monkeysphere, if I am recalling correctly, has a
   hack to remove the $DISPLAY variable from the users environment, and then
   add it back in, but frankly this option frightens me, as unsetting the
   display could result in all X applications failing.
       Werner Koch's suggestions, from the gnupg-devel mailing list are:
   http://lists.gnupg.org/pipermail/gnupg-users/2007-April/030927.html
       And, for the record, '--no-use-agent' doesn't disable pinentry.
2013-05-11 18:03:41 +00:00
Isis Lovecruft 7779a87fac
Ignore socket configuration files for emacs. 2013-05-11 17:33:09 +00:00
Isis Lovecruft 458b8a4c2c
Remove unused logger statement. 2013-05-11 14:48:45 +00:00
Isis Lovecruft adaf53c256
Fix a call in a unittest to _make_binary_stream() to call the correct module. 2013-05-11 08:55:47 +00:00
Isis Lovecruft 79bf77a185
Update test_import_and_export() unittest with newer key generation utility. 2013-05-11 08:54:17 +00:00
Isis Lovecruft 6c87679e7e
Fix a bug in two unittests caused by a method not having been renamed. 2013-05-11 08:53:12 +00:00
Isis Lovecruft ed2bc4d882
Split the old test_encryption_and_decryption() up into several smaller tests. 2013-05-11 08:51:48 +00:00
Isis Lovecruft 228cec9533
Add all available key fields for GPG.gen_key_input to the docstring. 2013-05-11 08:49:37 +00:00
Isis Lovecruft 863ad194a5
Cleanup indentation style a bit. 2013-05-11 08:48:39 +00:00
Isis Lovecruft b562a346ff
Fix typo in docstring. 2013-05-11 08:48:12 +00:00
Isis Lovecruft a7afce0394
Add a testing mode to GPG.gen_key_input() which uses insecure PRNG.
* This should only be used in the unittests, as the PRNG it uses in GnuPG does
   not create strong keypairs (though it's faster, thus why we're using it for
   testing).
2013-05-11 08:43:33 +00:00
Isis Lovecruft f95c3c7c1e
Remove old TODO comment. 2013-05-10 09:50:56 +00:00
Isis Lovecruft d392265101
Fix two bugs, one due to an extra pair of quotes, the other due to strformat. 2013-05-10 09:45:39 +00:00
Isis Lovecruft b66fc4ca82
Add subkey support and a docstring to GPG.export_keys(). 2013-05-10 09:44:07 +00:00
Isis Lovecruft 55185d528b
Separate options into tidy groups so that the parser handles them efficiently. 2013-05-10 09:42:30 +00:00