Commit 44d64bb1 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

Burnin: Small code refactoring

parent eb523a67
......@@ -245,18 +245,6 @@ class Log(object):
assert output_dir
# Create file for logging
output_dir = os.path.expanduser(output_dir)
if not os.path.exists(output_dir):
self.debug(None, "Creating directory %s", output_dir)
try:
os.makedirs(output_dir)
except OSError as err:
msg = ("Failed to create folder \"%s\" with error: %s\n"
% (output_dir, err))
sys.stderr.write(msg)
sys.exit("Failed to create log folder")
if curr_time is None:
curr_time = datetime.datetime.now()
timestamp = datetime.datetime.strftime(
......@@ -267,16 +255,29 @@ class Log(object):
self._write_to_stdout(None, "Starting burnin with id %s\n" % timestamp)
# Create the logging file
self._create_logging_file(timestamp)
self._create_logging_file(timestamp, output_dir)
def _create_logging_file(self, timestamp):
def _create_logging_file(self, timestamp, output_dir):
"""Create the logging file"""
if self.log_level > 1:
return
# Create file for logging
output_dir = os.path.expanduser(output_dir)
if not os.path.exists(output_dir):
self.debug(None, "Creating directory %s", output_dir)
try:
os.makedirs(output_dir)
except OSError as err:
msg = ("Failed to create folder \"%s\" with error: %s\n"
% (output_dir, err))
sys.stderr.write(msg)
sys.exit("Failed to create log folder")
self.debug(None, "Using \"%s\" file for logging", self.file_location)
with open(self.file_location, 'w') as out_file:
out_file.write(SECTION_SEPARATOR + "\n")
out_file.write("%s%s (%s):\n\n\n\n" %
out_file.write("%s%s with id %s:\n\n\n\n" %
(SECTION_PREFIX, SECTION_RUNNED, timestamp))
out_file.write(SECTION_SEPARATOR + "\n")
out_file.write("%s%s:\n\n" % (SECTION_PREFIX, SECTION_RESULTS))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment