summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
W. Trevor King [Sun, 20 Jan 2013 19:53:43 +0000 (14:53 -0500)]
MANIFEST.in: Distribute COPYING
W. Trevor King [Sun, 20 Jan 2013 19:53:13 +0000 (14:53 -0500)]
COPYING: Add text of GPLv3
W. Trevor King [Sun, 20 Jan 2013 19:49:54 +0000 (14:49 -0500)]
README.rst: Add symlink for GitHub rendering
W. Trevor King [Sun, 20 Jan 2013 19:25:23 +0000 (14:25 -0500)]
README: Every stand-alone project desrves one
This is based on my usual template. I also simplified the docstring
in mutt_ldap.py to stay DRY, since that information is now in the
README.
W. Trevor King [Sun, 20 Jan 2013 19:25:01 +0000 (14:25 -0500)]
.gitignore: Ignore *.pyc (generated when you run setup.py)
W. Trevor King [Sun, 20 Jan 2013 19:23:21 +0000 (14:23 -0500)]
setup.py: Package Mutt-LDAP using distutils
W. Trevor King [Sun, 20 Jan 2013 19:13:42 +0000 (14:13 -0500)]
mutt_ldap.py: Rename with underscore for package import
If I'm breaking Mutt-LDAP as a stand-alone package, I should probably
make it importable. Even if nobody else imports it, we can still want
this for setup.py-based installation.
W. Trevor King [Sun, 20 Jan 2013 17:59:40 +0000 (12:59 -0500)]
CachedLDAPConnection: Lazy LDAP connections
This is faster, and it allows us to return cached results even when
the LDAP server is not available (e.g. if your network is down).
W. Trevor King [Sun, 20 Jan 2013 17:50:10 +0000 (12:50 -0500)]
Add logging to stdout (via StreamHandler)
This makes it easy to trace execution and make sure everything is
happening as you think it should. There's currently no command-line
switch to increase verbosity. Once we drop support for Python 2.6,
I'll put in an argparse.ArgumentParser.
W. Trevor King [Sun, 20 Jan 2013 16:55:54 +0000 (11:55 -0500)]
CachedLDAPConnection: Convert cache format from Pickle to JSON
Now that we're only storing text fields (via the cache.fields
configuration setting), this is pretty easy to change.
W. Trevor King [Sun, 20 Jan 2013 16:48:11 +0000 (11:48 -0500)]
CachedLDAPConnection: Drop the old cache on version missmatch
The expected CachedLDAPConnection._cache_version tracks __version__,
so if you bump __version__, you invalidate the existing cache. There
shouldn't be anything critical in the cache, and this is safer than
trying to remember to bump an independent _cache_version after major
changes.
W. Trevor King [Sun, 20 Jan 2013 16:47:38 +0000 (11:47 -0500)]
Add a __version__ (for easier compatibility tracking)
W. Trevor King [Sun, 20 Jan 2013 16:39:50 +0000 (11:39 -0500)]
CachedLDAPConnection: Add support for cache.longevity-days
Cull entries older than longevity-days (defaults to 14). This
requires changing the cache values from a list of entries to a dict
with 'time' and 'entries' keys. Hmm, I should probably add a
reasonable cache versioning scheme...
W. Trevor King [Sun, 20 Jan 2013 16:25:40 +0000 (11:25 -0500)]
Prefix imported modules with underscores
This cleans up the namespace inside the module, and makes it less
likely that you'll clobber an imported module with a local variable
name. I also removed imports for modules we no longer use.
W. Trevor King [Sun, 20 Jan 2013 16:22:39 +0000 (11:22 -0500)]
Alphebetize standard library imports
W. Trevor King [Sun, 20 Jan 2013 16:19:12 +0000 (11:19 -0500)]
Use hyphenated configuration options (instead of underscores)
I like them better ;).
W. Trevor King [Sun, 20 Jan 2013 16:07:50 +0000 (11:07 -0500)]
CachedLDAPConnection: Don't cache fields we don't use
I had previously said:
> It would be nice to automatically detect and drop any non text
> fields, but that's probably not worth the trouble either...
Since the configuration ID is in the cached key, we already know
exactly which fields we need to save in the cache. Only caching those
fields avoids binary fields and fields with large values (jpegPhoto is
both). I made the cached fields configurable because the
CachedLDAPConnection instance doesn't know about the fields needed by
format_entry() and format_columns(). If you don't configure the
cached fields, a minimal default is setup in the main block.
W. Trevor King [Sun, 20 Jan 2013 15:48:19 +0000 (10:48 -0500)]
Restructure around an LDAPConnection class
This keeps us organized and simplifies the connection API (using the
'with' statement).
I also simplified the cache structure to keep all cached entries in a
single pickled dict, to avoid calculating safe filenames for each
query. The number of queries you make in 14 days will probably not be
large enough for any fan-out efficiencies to be worth the trouble.
I considered using JSON instead of Pickle, but JSON does not support
raw byte strings (e.g. jpegPhoto), and it's not worth encoding
non-text fields using Base64, etc., when Pickle already works.
It would be nice to automatically detect and drop any non text fields,
but that's probably not worth the trouble either...
W. Trevor King [Sun, 20 Jan 2013 14:33:47 +0000 (09:33 -0500)]
Decode search results to Unicode and print as Unicode
LDAPv3 strings are encoded in UTF-8 [1], so use that encoding to
decode them in format_columns(). Adjust format_entry() and the main
block to handle the Unicode output from format_columns().
[1]: http://tools.ietf.org/html/rfc2251#section-4.1.2
W. Trevor King [Sun, 20 Jan 2013 13:35:03 +0000 (08:35 -0500)]
Bump my copyright to 2013 and add Niels de Vos
W. Trevor King [Sun, 20 Jan 2013 13:34:13 +0000 (08:34 -0500)]
Adapt to Unicode sys.argv
W. Trevor King [Sun, 20 Jan 2013 13:26:54 +0000 (08:26 -0500)]
Convert sys.argv to Unicode (using a configurable encoding)
In Python 3, sys.argv is already Unicode, but there's no clean way to
do this automatically in Python 2 [1]. If your system doesn't use
UTF-8 for it's argv encoding, you should set system.argv-encoding in
your ~/.mutt-ldap.rc. For example, if your system uses UTF-16, try:
[system]
argv-encoding = utf-16
[1]: http://bugs.python.org/issue2128
W. Trevor King [Sun, 20 Jan 2013 13:22:38 +0000 (08:22 -0500)]
search: Move asynchronous result handling inside search()
The result of search() should be an iterable returning entries. If we
want to use the asynchronous connection.search() and
connection.result(), that's fine, but we should handle the result
unpacking inside search().
One benefit to Wade's new generator approach is that we can start
formatting early entries while we wait for later entries to arrive.
W. Trevor King [Sun, 20 Jan 2013 12:03:29 +0000 (07:03 -0500)]
search: `post` and `query` should be Unicode strings
They're being formatted into the Unicode `filterstr`. Being explicit
here should make the transition to Python 3 less annoying.
W. Trevor King [Sun, 20 Jan 2013 17:17:57 +0000 (12:17 -0500)]
Merge remote-tracking branch 'wberrier/master' into master
* wberrier/master:
prevent an error when no search string is given
Return partial results if the search takes a long time
implement caching system for big/slow ldap servers
make search fields configurable
Add support for an optional display column
Fix for python 2.6: add position indexes to format strings
Add query filter section (in order to pare down results)
Return results in a format that mutt expects
fix typo in reference to .rc file
Add Wade Berrier (me) to author/copyright list
Niels de Vos [Thu, 13 Dec 2012 09:35:05 +0000 (10:35 +0100)]
prevent an error when no search string is given
Wade Berrier [Sun, 20 Jan 2013 02:54:43 +0000 (19:54 -0700)]
Return partial results if the search takes a long time
An impartial result is better than no result. Done by requiring search
to have a pre-allocated connection.
Wade Berrier [Wed, 27 Jun 2012 16:10:42 +0000 (10:10 -0600)]
implement caching system for big/slow ldap servers
Wade Berrier [Wed, 27 Jun 2012 07:33:11 +0000 (01:33 -0600)]
make search fields configurable
Wade Berrier [Sun, 20 Jan 2013 01:34:51 +0000 (18:34 -0700)]
Add support for an optional display column
Again, according to http://www.mutt.org/doc/manual/manual-4.html#ss4.5
Wade Berrier [Sun, 20 Jan 2013 01:02:10 +0000 (18:02 -0700)]
Fix for python 2.6: add position indexes to format strings
Turns out that omitting the indexes is only supported in python >= 2.7
It's possible this script would work with python < 2.6 but the old
format strings would be necessary
Wade Berrier [Sat, 19 Jan 2013 21:05:59 +0000 (14:05 -0700)]
Add query filter section (in order to pare down results)
Wade Berrier [Sat, 19 Jan 2013 20:55:41 +0000 (13:55 -0700)]
Return results in a format that mutt expects
According to: http://www.mutt.org/doc/manual/manual-4.html#ss4.5
Wade Berrier [Sat, 19 Jan 2013 20:46:28 +0000 (13:46 -0700)]
fix typo in reference to .rc file
Wade Berrier [Sat, 19 Jan 2013 20:44:07 +0000 (13:44 -0700)]
Add Wade Berrier (me) to author/copyright list
W. Trevor King [Fri, 28 Sep 2012 00:08:16 +0000 (20:08 -0400)]
posts:ldap: update Python scripts to explicitly use Python 2.
python-ldap doesn't have a Python 3 version yet. I made a few other
changes to increase Python 3 compatibility, and added a full copyright
blurb to abook-ldif-cleanup.py.
W. Trevor King [Wed, 15 Aug 2012 14:13:20 +0000 (10:13 -0400)]
Also search on displayName in mutt-ldap.py and ldap-jpeg.py.
Also prefer displayName to cn when formatting names.
W. Trevor King [Mon, 14 May 2012 13:21:57 +0000 (09:21 -0400)]
Add starttls support to mutt-ldap.py and ldap-jpeg.py.
Also remove `rdn` from the searched attributes, because I don't have
such a field in any of my schemas.
W. Trevor King [Fri, 11 May 2012 06:10:12 +0000 (02:10 -0400)]
Add auth.gssapi option to mutt-ldap.py (for use with Kerberos).
W. Trevor King [Tue, 21 Jun 2011 12:26:01 +0000 (08:26 -0400)]
Add GnuTLS and secure LDAP information.
W. Trevor King [Sat, 18 Jun 2011 18:32:05 +0000 (14:32 -0400)]
Add mutt-ldap.py.