mutt_ldap.py: Don't load the config file if were being imported as a library
authorW. Trevor King <wking@tremily.us>
Thu, 24 Jan 2013 22:24:49 +0000 (17:24 -0500)
committerW. Trevor King <wking@tremily.us>
Thu, 24 Jan 2013 22:32:13 +0000 (17:32 -0500)
mutt_ldap.py

index dab031c76fdd6e041f767b08a90d5f55848443c7..64e4da4ff525fafd98b1ce44fd5d8327f4c26ac5 100755 (executable)
@@ -65,8 +65,6 @@ CONFIG.set('system', 'output-encoding', '')  # match .muttrc's $charset
 # HACK: Python 2.x support, see http://bugs.python.org/issue2128
 CONFIG.set('system', 'argv-encoding', '')
 
-CONFIG.read(_os_path.expanduser('~/.mutt-ldap.rc'))
-
 
 class LDAPConnection (object):
     """Wrap an LDAP connection supporting the 'with' statement
@@ -270,6 +268,8 @@ if __name__ == '__main__':
     import locale as _locale
     import sys as _sys
 
+    read_configfiles = CONFIG.read(_os_path.expanduser('~/.mutt-ldap.rc'))
+
     default_encoding = _locale.getpreferredencoding(do_setlocale=True)
     for key in ['output-encoding', 'argv-encoding']:
         CONFIG.set(
@@ -284,6 +284,8 @@ if __name__ == '__main__':
     argv_encoding = CONFIG.get('system', 'argv-encoding')
     _sys.argv = [unicode(arg, argv_encoding) for arg in _sys.argv]
 
+    LOG.info(u'loaded configuration from {0}'.format(read_configfiles))
+
     if len(_sys.argv) < 2:
         _sys.stderr.write(
             u'{0}: no search string given\n'.format(_sys.argv[0]))