import textwrap
import socket
import re
+import traceback
# Third party modules
# from ldap3 import ObjectDef, AttrDef, Reader, Writer
from .ldap_app import PpLdapAppError, PpLdapApplication
-__version__ = '0.4.3'
+__version__ = '0.4.4'
LOG = logging.getLogger(__name__)
LOG.debug("Evaluating config section {n!r}:\n{s}".format(
n=section_name, s=pp(section)))
- if not 'admin_group' in section:
+ if 'admin_group' not in section:
return
admin_group = str(section['admin_group']).strip()
section['host'], section_name))
else:
try:
- _ = socket.getaddrinfo(host, 5432, proto=socket.IPPROTO_TCP)
+ _ = socket.getaddrinfo(host, 5432, proto=socket.IPPROTO_TCP) # noqa
except socket.gaierror as e:
msg = 'Invalid hostname {!r} in configuration section {!r}: {}'.format(
section['host'], section_name, e)
raise ValueError("port number must be less than {}".format((2 ** 16)))
except (ValueError, TypeError) as e:
msg = 'Invalid port number {!r} in configuration section {!r}: {}'.format(
- section['port'],section_name, e)
+ section['port'], section_name, e)
LOG.error(msg)
self.config_has_errors = True
else:
self.connect_db()
- # -------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
def connect_db(self):
result = None
self.admin_user_dns = []
- query_filter = ('(&(|(objectclass=groupOfUniqueNames)(objectclass=groupOfURLs))'
- '({}))').format(self.admin_group)
+ query_filter = (
+ '(&(|(objectclass=groupOfUniqueNames)(objectclass=groupOfURLs))({}))').format(
+ self.admin_group)
LOG.debug("Query filter: {!r}".format(query_filter))
group = ObjectDef(['objectclass', 'groupOfURLs'])
group += ['cn', 'memberURL', 'uniqueMember']
- group_entries = self.ldap_search_subtree(group, query_filter)
+ group_entries = self.ldap_search_subtree(group, query_filter)
if self.verbose > 1:
LOG.debug("Found {} LDAP entries.".format(len(group_entries)))
'(&(objectclass=posixAccount)(objectclass=shadowAccount)'
'(uid={}))').format(uid)
if self.verbose > 2:
- LOG.debug("Query filter: {!r}".format(query_filter))
+ LOG.debug("Query filter: {!r}".format(query_filter))
entries = self.ldap_search_subtree(person, query_filter)
if self.verbose > 2:
n=db_user['name'], u=uid))
else:
if db_user['active'] != 0:
- LOG.warn("DB user {n!r} ({u}) does not exists anymore, will be dectivated.".format(
- n=db_user['name'], u=uid))
+ LOG.warn(
+ "DB user {n!r} ({u}) does not exists anymore, will be dectivated.".format(
+ n=db_user['name'], u=uid))
self.db_users_deactivate.append(db_id)
else:
LOG.debug("User {n!r} ({u}) is already dectivated.".format(
for db_user in self.users_to_update:
- #LOG.warn("Updating user {n!r} ({u}) ...".format(n=db_user['name'], u=db_user['uid']))
+ # LOG.warn(
+ # "Updating user {n!r} ({u}) ...".format(
+ # n=db_user['name'], u=db_user['uid']))
msg = "Udating user db id {}:".format(db_user['id'])
sql = 'UPDATE public.user SET'