Revision 828bbf06

b/snf-tools/synnefo_tools/burnin/logger.py
245 245

  
246 246
        assert output_dir
247 247

  
248
        # Create file for logging
249
        output_dir = os.path.expanduser(output_dir)
250
        if not os.path.exists(output_dir):
251
            self.debug(None, "Creating directory %s", output_dir)
252
            try:
253
                os.makedirs(output_dir)
254
            except OSError as err:
255
                msg = ("Failed to create folder \"%s\" with error: %s\n"
256
                       % (output_dir, err))
257
                sys.stderr.write(msg)
258
                sys.exit("Failed to create log folder")
259

  
260 248
        if curr_time is None:
261 249
            curr_time = datetime.datetime.now()
262 250
        timestamp = datetime.datetime.strftime(
......
267 255
        self._write_to_stdout(None, "Starting burnin with id %s\n" % timestamp)
268 256

  
269 257
        # Create the logging file
270
        self._create_logging_file(timestamp)
258
        self._create_logging_file(timestamp, output_dir)
271 259

  
272
    def _create_logging_file(self, timestamp):
260
    def _create_logging_file(self, timestamp, output_dir):
273 261
        """Create the logging file"""
274 262
        if self.log_level > 1:
275 263
            return
264

  
265
        # Create file for logging
266
        output_dir = os.path.expanduser(output_dir)
267
        if not os.path.exists(output_dir):
268
            self.debug(None, "Creating directory %s", output_dir)
269
            try:
270
                os.makedirs(output_dir)
271
            except OSError as err:
272
                msg = ("Failed to create folder \"%s\" with error: %s\n"
273
                       % (output_dir, err))
274
                sys.stderr.write(msg)
275
                sys.exit("Failed to create log folder")
276

  
276 277
        self.debug(None, "Using \"%s\" file for logging", self.file_location)
277 278
        with open(self.file_location, 'w') as out_file:
278 279
            out_file.write(SECTION_SEPARATOR + "\n")
279
            out_file.write("%s%s (%s):\n\n\n\n" %
280
            out_file.write("%s%s with id %s:\n\n\n\n" %
280 281
                           (SECTION_PREFIX, SECTION_RUNNED, timestamp))
281 282
            out_file.write(SECTION_SEPARATOR + "\n")
282 283
            out_file.write("%s%s:\n\n" % (SECTION_PREFIX, SECTION_RESULTS))

Also available in: Unified diff