First iteration of logging cleanup.

This commit is contained in:
Darko Poljak 2017-06-28 23:36:42 +02:00 committed by Steven Armstrong
commit 248656b81f
8 changed files with 49 additions and 49 deletions

View file

@ -163,7 +163,7 @@ class Local(object):
with open(self.object_marker_file, 'w') as fd:
fd.write("%s\n" % self.object_marker_name)
self.log.debug("Object marker %s saved in %s" % (
self.log.trace("Object marker %s saved in %s" % (
self.object_marker_name, self.object_marker_file))
def _init_cache_dir(self, cache_dir):
@ -178,12 +178,12 @@ class Local(object):
def rmdir(self, path):
"""Remove directory on the local side."""
self.log.debug("Local rmdir: %s", path)
self.log.trace("Local rmdir: %s", path)
shutil.rmtree(path)
def mkdir(self, path):
"""Create directory on the local side."""
self.log.debug("Local mkdir: %s", path)
self.log.trace("Local mkdir: %s", path)
os.makedirs(path, exist_ok=True)
def run(self, command, env=None, return_output=False, message_prefix=None,
@ -192,7 +192,7 @@ class Local(object):
Return the output as a string.
"""
self.log.debug("Local run: %s", command)
self.log.trace("Local run: %s", command)
assert isinstance(command, (list, tuple)), (
"list or tuple argument expected, got: %s" % command)
@ -214,9 +214,9 @@ class Local(object):
try:
if save_output:
output, errout = exec_util.call_get_output(command, env=env)
self.log.debug("Local stdout: {}".format(output))
self.log.trace("Local stdout: {}".format(output))
# Currently, stderr is not captured.
# self.log.debug("Local stderr: {}".format(errout))
# self.log.trace("Local stderr: {}".format(errout))
if return_output:
return output.decode()
else:
@ -279,7 +279,7 @@ class Local(object):
return cache_subpath
def save_cache(self, start_time=time.time()):
self.log.debug("cache subpath pattern: {}".format(
self.log.trace("cache subpath pattern: {}".format(
self.cache_path_pattern))
cache_subpath = self._cache_subpath(start_time,
self.cache_path_pattern)
@ -340,7 +340,7 @@ class Local(object):
if os.path.exists(dst):
os.unlink(dst)
self.log.debug("Linking %s to %s ..." % (src, dst))
self.log.trace("Linking %s to %s ..." % (src, dst))
try:
os.symlink(src, dst)
except OSError as e:
@ -352,7 +352,7 @@ class Local(object):
src = os.path.abspath(self.exec_path)
for cdist_type in core.CdistType.list_types(self.type_path):
dst = os.path.join(self.bin_path, cdist_type.name)
self.log.debug("Linking emulator: %s to %s", src, dst)
self.log.trace("Linking emulator: %s to %s", src, dst)
try:
os.symlink(src, dst)

View file

@ -111,17 +111,17 @@ class Remote(object):
def rmdir(self, path):
"""Remove directory on the remote side."""
self.log.debug("Remote rmdir: %s", path)
self.log.trace("Remote rmdir: %s", path)
self.run(["rm", "-rf", path])
def mkdir(self, path):
"""Create directory on the remote side."""
self.log.debug("Remote mkdir: %s", path)
self.log.trace("Remote mkdir: %s", path)
self.run(["mkdir", "-p", path])
def transfer(self, source, destination, jobs=None):
"""Transfer a file or directory to the remote side."""
self.log.debug("Remote transfer: %s -> %s", source, destination)
self.log.trace("Remote transfer: %s -> %s", source, destination)
self.rmdir(destination)
if os.path.isdir(source):
self.mkdir(destination)
@ -147,11 +147,11 @@ class Remote(object):
def _transfer_dir_parallel(self, source, destination, jobs):
"""Transfer a directory to the remote side in parallel mode."""
self.log.info("Remote transfer in {} parallel jobs".format(
self.log.debug("Remote transfer in {} parallel jobs".format(
jobs))
self.log.debug("Multiprocessing start method is {}".format(
self.log.trace("Multiprocessing start method is {}".format(
multiprocessing.get_start_method()))
self.log.debug(("Starting multiprocessing Pool for parallel "
self.log.trace(("Starting multiprocessing Pool for parallel "
"remote transfer"))
args = []
for f in glob.glob1(source, '*'):
@ -161,7 +161,7 @@ class Remote(object):
_wrap_addr(self.target_host[0]), destination)])
args.append((command, ))
mp_pool_run(self._run_command, args, jobs=jobs)
self.log.debug(("Multiprocessing for parallel transfer "
self.log.trace(("Multiprocessing for parallel transfer "
"finished"))
def run_script(self, script, env=None, return_output=False):
@ -226,12 +226,12 @@ class Remote(object):
os_environ['__target_hostname'] = self.target_host[1]
os_environ['__target_fqdn'] = self.target_host[2]
self.log.debug("Remote run: %s", command)
self.log.trace("Remote run: %s", command)
try:
output, errout = exec_util.call_get_output(command, env=os_environ)
self.log.debug("Remote stdout: {}".format(output))
self.log.trace("Remote stdout: {}".format(output))
# Currently, stderr is not captured.
# self.log.debug("Remote stderr: {}".format(errout))
# self.log.trace("Remote stderr: {}".format(errout))
if return_output:
return output.decode()
except subprocess.CalledProcessError as e: