summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2015-12-01 15:49:18 +0100
committerasteroide <thomas.duval@orange.com>2015-12-01 15:49:18 +0100
commit0975e3186a8aa83e3496f4e6891c8d934bee3d5f (patch)
tree5141426652ab2037ca41ea5061da3e8b0db1e4c5
parente0b8eff4c04322d8f081d41c02b2465034449743 (diff)
Add date and time in log files.
Change-Id: I07a148c01afcab0330e4d95d118439635908013d
-rw-r--r--moonclient/moonclient/tests.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/moonclient/moonclient/tests.py b/moonclient/moonclient/tests.py
index fb4daa69..3bef6b9d 100644
--- a/moonclient/moonclient/tests.py
+++ b/moonclient/moonclient/tests.py
@@ -23,10 +23,15 @@ class TestsLaunch(Lister):
result_vars = dict()
logfile_name = "/tmp/moonclient_test_{}.log".format(time.strftime("%Y%m%d-%H%M%S"))
logfile = open(logfile_name, "w")
+ TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
def get_parser(self, prog_name):
parser = super(TestsLaunch, self).get_parser(prog_name)
parser.add_argument(
+ '--stop-on-error',
+ help='Stop the test on the first error',
+ )
+ parser.add_argument(
'testfile',
metavar='<filename(s)>',
help='Filenames that contains tests to run '
@@ -130,7 +135,7 @@ class TestsLaunch(Lister):
if port:
title += ":" + port
title += "\n"
- self.logfile.write(title + "\n")
+ self.logfile.write(time.strftime(self.TIME_FORMAT) + " " + title + "\n")
self.log.info(title)
data_tmp = list()
data_tmp.append("")
@@ -149,7 +154,7 @@ class TestsLaunch(Lister):
else:
continue
ext_command = self.__replace_var_in_str(ext_command)
- self.logfile.write("-----> {}\n".format(ext_command))
+ self.logfile.write(time.strftime(self.TIME_FORMAT) + " " + "-----> {}\n".format(ext_command))
self.log.info(" \\-executing external \"{}\"".format(ext_command))
pipe = subprocess.Popen(shlex.split(ext_command), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
com = pipe.communicate()
@@ -163,7 +168,7 @@ class TestsLaunch(Lister):
else:
command = test["command"] + " " + global_command_options
command = self.__replace_var_in_str(command)
- self.logfile.write("-----> {}\n".format(command))
+ self.logfile.write(time.strftime(self.TIME_FORMAT) + " " + "-----> {}\n".format(command))
self.log.info(" \\-executing {}".format(command))
self.app.stdout = tmp_filename_fd
result_id = self.app.run_subcommand(shlex.split(command))