Skip to content

Commit

Permalink
no global _LOG_LEVEL, make pylint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Apr 28, 2017
1 parent b6e058e commit a40ee18
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions Lib/slapdtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
See http://www.python-ldap.org/ for details.
\$Id: slapdtest.py,v 1.9 2017/04/28 07:30:58 stroeder Exp $
$Id: slapdtest.py,v 1.10 2017/04/28 08:59:09 stroeder Exp $
Python compability note:
This module only works with Python 2.7.x since
Expand All @@ -21,16 +21,6 @@
import unittest
import urllib

# determine log level
try:
_LOG_LEVEL = os.environ['LOGLEVEL']
try:
_LOG_LEVEL = int(_LOG_LEVEL)
except ValueError:
pass
except KeyError:
_LOG_LEVEL = logging.WARN

# a template string for generating simple slapd.conf file
SLAPD_CONF_TEMPLATE = r"""
serverID %(serverid)s
Expand All @@ -54,14 +44,20 @@

def combined_logger(
log_name,
log_level=_LOG_LEVEL,
log_level=logging.WARN,
sys_log_format='%(levelname)s %(message)s',
console_log_format='%(asctime)s %(levelname)s %(message)s',
):
"""
Returns a combined SysLogHandler/StreamHandler logging instance
with formatters
"""
if 'LOGLEVEL' in os.environ:
log_level = os.environ['LOGLEVEL']
try:
log_level = int(log_level)
except ValueError:
pass
# for writing to syslog
new_logger = logging.getLogger(log_name)
if sys_log_format:
Expand All @@ -81,6 +77,7 @@ def combined_logger(
new_logger.setLevel(log_level)
return new_logger # end of combined_logger()


class SlapdObject(object):
"""
Controller class for a slapd instance, OpenLDAP's server.
Expand Down Expand Up @@ -247,8 +244,8 @@ def start(self):
"""
Starts the slapd server process running, and waits for it to come up.
"""

if self._proc is None:
config_path = None
# prepare directory structure
self._cleanup_rundir()
self._setup_rundir()
Expand Down Expand Up @@ -346,6 +343,7 @@ class SlapdTestCase(unittest.TestCase):

server_class = SlapdObject
server = None
ldap_object_class = None

def _open_ldap_conn(self, who=None, cred=None):
"""
Expand Down

0 comments on commit a40ee18

Please sign in to comment.