Skip to content

Commit

Permalink
Use logging module instead of print
Browse files Browse the repository at this point in the history
This commit switches the realm code to use the logging module
instead of just calling `print` (making the output more managable).
  • Loading branch information
DirectXMan12 committed Nov 18, 2015
1 parent b6d733d commit 27eae50
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions k5test/realm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@
import sys
import subprocess
import tempfile
import logging

import six

from k5test import _utils


_LOG = logging.getLogger(__name__)


def _cfg_merge(cfg1, cfg2):
if not cfg2:
return cfg1
Expand Down Expand Up @@ -167,12 +171,12 @@ def _discover_path(self, name, default, paths):
stderr=stderr_out).strip()
path = path.decode(sys.getfilesystemencoding() or
sys.getdefaultencoding())
print("Using discovered path for {name} ({path}".format(
_LOG.debug("Using discovered path for {name} ({path}".format(
name=name, path=path))
return path
except subprocess.CalledProcessError as e:
path = paths.get(name, default)
print("Using default path for {name} ({path}): {err}".format(
_LOG.debug("Using default path for {name} ({path}): {err}".format(
name=name, path=path, err=e))
return path

Expand Down Expand Up @@ -281,8 +285,8 @@ def run(self, args, env=None, input=None, expected_code=0):
code = proc.returncode
cmd = ' '.join(args)
outstr = outdata.decode()
print('[OUTPUT FROM `{args}`]\n{output}\n'.format(args=cmd,
output=outstr))
_LOG.debug('[OUTPUT FROM `{args}`]\n{output}\n'.format(args=cmd,
output=outstr))
if code != expected_code:
raise Exception("Unexpected return code "
"for command `{args}`: {code}".format(args=cmd,
Expand Down Expand Up @@ -315,8 +319,8 @@ def _start_daemon(self, args, env, sentinel):
'with code {code}'.format(args=cmd,
code=code))
else:
print('[OUTPUT FROM `{args}`]\n'
'{output}\n'.format(args=cmd, output=line))
_LOG.debug('[OUTPUT FROM `{args}`]\n'
'{output}\n'.format(args=cmd, output=line))

if sentinel in line:
break
Expand Down

0 comments on commit 27eae50

Please sign in to comment.