From 0f0839becd7db36bb527e5b57d1042cd2573076e Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 4 Jul 2017 10:46:53 +0200 Subject: [PATCH] Returning to Python3, Bugfixing in pp_lib/ldap_app.py --- mk-home | 2 +- pp_lib/ldap_app.py | 14 ++++++-------- quota-check | 2 +- test-home | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/mk-home b/mk-home index c5e9e25..dec4def 100755 --- a/mk-home +++ b/mk-home @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Standard modules import sys diff --git a/pp_lib/ldap_app.py b/pp_lib/ldap_app.py index d8964a9..91c655d 100644 --- a/pp_lib/ldap_app.py +++ b/pp_lib/ldap_app.py @@ -26,7 +26,7 @@ import ldap3 # ldap3 classes and objects from ldap3 import Server, ServerPool, Connection, Reader, Writer, ObjectDef # ldap3 constants -from ldap3 import IP_V4_PREFERRED, ROUND_ROBIN, AUTO_BIND_NONE, ALL_ATTRIBUTES +from ldap3 import IP_V4_ONLY, IP_V4_PREFERRED, ROUND_ROBIN, AUTO_BIND_NONE, ALL_ATTRIBUTES from ldap3 import SUBTREE from ldap3.core.exceptions import LDAPPasswordIsMandatoryError @@ -126,13 +126,13 @@ class PpLdapApplication(PpConfigApplication): cfg_encoding=cfg_encoding, need_config_file=need_config_file, ) - if self.verbose > 3: + if self.verbose > 5: set_library_log_detail_level(EXTENDED) - elif self.verbose > 2: + elif self.verbose > 4: set_library_log_detail_level(NETWORK) - elif self.verbose > 1: + elif self.verbose > 3: set_library_log_detail_level(PROTOCOL) - elif self.verbose: + elif self.verbose > 2: set_library_log_detail_level(BASIC) else: set_library_log_detail_level(ERROR) @@ -212,13 +212,11 @@ class PpLdapApplication(PpConfigApplication): mode=IP_V4_PREFERRED, connect_timeout=self.ldap_timeout) # Init LDAP Server objects - if len(self.ldap_hosts) > 1: + if len(self.ldap_hosts): self.ldap_server = ServerPool(None, ROUND_ROBIN) for h in self.ldap_hosts: server = _get_ldap_server(h) self.ldap_server.add(server) - elif len(self.ldap_hosts) == 1: - self.ldap_server = _get_ldap_server(self.ldap_hosts[0]) else: msg = "No LDAP servers found in configuration." raise PpLdapAppError(msg) diff --git a/quota-check b/quota-check index af46130..35a0ad1 100755 --- a/quota-check +++ b/quota-check @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- from __future__ import print_function diff --git a/test-home b/test-home index fd23328..32eb03e 100755 --- a/test-home +++ b/test-home @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Standard modules import sys -- 2.39.5