Skip to content

Commit 27eae50

Browse files
committed
Use logging module instead of print
This commit switches the realm code to use the logging module instead of just calling `print` (making the output more managable).
1 parent b6d733d commit 27eae50

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

k5test/realm.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@
3131
import sys
3232
import subprocess
3333
import tempfile
34+
import logging
3435

3536
import six
3637

3738
from k5test import _utils
3839

3940

41+
_LOG = logging.getLogger(__name__)
42+
43+
4044
def _cfg_merge(cfg1, cfg2):
4145
if not cfg2:
4246
return cfg1
@@ -167,12 +171,12 @@ def _discover_path(self, name, default, paths):
167171
stderr=stderr_out).strip()
168172
path = path.decode(sys.getfilesystemencoding() or
169173
sys.getdefaultencoding())
170-
print("Using discovered path for {name} ({path}".format(
174+
_LOG.debug("Using discovered path for {name} ({path}".format(
171175
name=name, path=path))
172176
return path
173177
except subprocess.CalledProcessError as e:
174178
path = paths.get(name, default)
175-
print("Using default path for {name} ({path}): {err}".format(
179+
_LOG.debug("Using default path for {name} ({path}): {err}".format(
176180
name=name, path=path, err=e))
177181
return path
178182

@@ -281,8 +285,8 @@ def run(self, args, env=None, input=None, expected_code=0):
281285
code = proc.returncode
282286
cmd = ' '.join(args)
283287
outstr = outdata.decode()
284-
print('[OUTPUT FROM `{args}`]\n{output}\n'.format(args=cmd,
285-
output=outstr))
288+
_LOG.debug('[OUTPUT FROM `{args}`]\n{output}\n'.format(args=cmd,
289+
output=outstr))
286290
if code != expected_code:
287291
raise Exception("Unexpected return code "
288292
"for command `{args}`: {code}".format(args=cmd,
@@ -315,8 +319,8 @@ def _start_daemon(self, args, env, sentinel):
315319
'with code {code}'.format(args=cmd,
316320
code=code))
317321
else:
318-
print('[OUTPUT FROM `{args}`]\n'
319-
'{output}\n'.format(args=cmd, output=line))
322+
_LOG.debug('[OUTPUT FROM `{args}`]\n'
323+
'{output}\n'.format(args=cmd, output=line))
320324

321325
if sentinel in line:
322326
break

0 commit comments

Comments
 (0)