Replacing 'print' with 'LOG.xxx'

It is recommended to use the print() function only in rally.cli module.
So this patch replaces the use of print() with LOG.xxx in the tempest.py
and api.py files.

Change-Id: Ifa8f9b708d002986926f5eb36c7a4ef0a2cbb131
This commit is contained in:
Yaroslav Lobankov 2015-10-03 18:04:05 +03:00
parent 654c63e328
commit 07e2b0e8d0
2 changed files with 12 additions and 10 deletions

View File

@ -329,8 +329,10 @@ class Verification(object):
tempest_config=tempest_config, tempest_config=tempest_config,
system_wide_install=system_wide_install) system_wide_install=system_wide_install)
if not verifier.is_installed(): if not verifier.is_installed():
print("Tempest is not installed for specified deployment.") LOG.info(_("Tempest is not installed "
print("Installing Tempest for deployment %s" % deployment_uuid) "for the specified deployment."))
LOG.info(_("Installing Tempest "
"for deployment: %s") % deployment_uuid)
verifier.install() verifier.install()
return verifier return verifier

View File

@ -180,7 +180,8 @@ class Tempest(object):
path_to_venv = self.path(".venv") path_to_venv = self.path(".venv")
if not os.path.isdir(path_to_venv): if not os.path.isdir(path_to_venv):
print("No virtual environment found...Install the virtualenv.") LOG.debug("No virtual environment for Tempest found.")
LOG.info(_("Installing the virtual environment for Tempest."))
LOG.debug("Virtual environment directory: %s" % path_to_venv) LOG.debug("Virtual environment directory: %s" % path_to_venv)
required_vers = (2, 7) required_vers = (2, 7)
if sys.version_info[:2] != required_vers: if sys.version_info[:2] != required_vers:
@ -238,7 +239,7 @@ class Tempest(object):
def _initialize_testr(self): def _initialize_testr(self):
if not os.path.isdir(self.path(".testrepository")): if not os.path.isdir(self.path(".testrepository")):
print(_("Test Repository initialization.")) LOG.debug("Test Repository initialization.")
try: try:
check_output("%s testr init" % self.venv_wrapper, check_output("%s testr init" % self.venv_wrapper,
shell=True, cwd=self.path()) shell=True, cwd=self.path())
@ -251,8 +252,7 @@ class Tempest(object):
return os.path.exists(self.path(".venv")) return os.path.exists(self.path(".venv"))
def _clone(self): def _clone(self):
print("Please wait while tempest is being cloned. " LOG.info(_("Please, wait while Tempest is being cloned."))
"This could take a few minutes...")
try: try:
subprocess.check_call(["git", "clone", subprocess.check_call(["git", "clone",
self.tempest_source, self.tempest_source,
@ -281,10 +281,10 @@ class Tempest(object):
self.uninstall() self.uninstall()
raise TempestSetupFailure("failed cmd: '%s'" % e.cmd) raise TempestSetupFailure("failed cmd: '%s'" % e.cmd)
else: else:
print("Tempest has been successfully installed!") LOG.info(_("Tempest has been successfully installed!"))
else: else:
print("Tempest is already installed") LOG.info(_("Tempest is already installed."))
def uninstall(self): def uninstall(self):
"""Removes local Tempest repo and virtualenv for deployment """Removes local Tempest repo and virtualenv for deployment
@ -311,8 +311,8 @@ class Tempest(object):
try: try:
self.run(testr_arg) self.run(testr_arg)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("Test set '%s' has been finished with error. " LOG.info(_("Test set '%s' has been finished with errors. "
"Check log for details" % set_name) "Check logs for details.") % set_name)
def run(self, testr_arg=None, log_file=None, tempest_conf=None): def run(self, testr_arg=None, log_file=None, tempest_conf=None):
"""Launch tempest with given arguments """Launch tempest with given arguments