def get_report_robot_filename_rd(self, id_robot):
     pattern = DirectoryStructure.pattern_report_robot
     filename = os.path.join(self.root, DirectoryStructure.DIR_REPORTS,
                            substitute(pattern, id_robot=id_robot))
     mkdirs_thread_safe(os.path.dirname(filename))
     rd = os.path.join(self.root, DirectoryStructure.DIR_REPORTS,
                         DirectoryStructure.pattern_report_rd)
     return filename, rd
 def get_report_filename(self, id_agent, id_robot, id_state, phase):
     pattern = DirectoryStructure.pattern_report
     filename = os.path.join(self.root, DirectoryStructure.DIR_REPORTS,
                            substitute(pattern,
                                       phase=phase,
                                       id_agent=id_agent,
                                       id_robot=id_robot,
                                       id_state=id_state))
     mkdirs_thread_safe(os.path.dirname(filename))
     return filename
 def get_report_res_dir(self, id_agent, id_robot, id_state, phase):
     ''' Returns the directory for the resources of the report. '''
     pattern = DirectoryStructure.pattern_report_rd
     dirname = os.path.join(self.root, DirectoryStructure.DIR_REPORTS,
                            substitute(pattern,
                                       phase=phase,
                                       id_agent=id_agent,
                                       id_robot=id_robot,
                                       id_state=id_state))
     mkdirs_thread_safe(dirname)
     assert os.path.exists(dirname)
     return dirname
    def get_log_filename(self, base_dir, id_agent, id_robot, id_stream,
                                  logs_format=None, add_unique=True):

        warn_good_identifier(id_stream)

        if logs_format is None:
            logs_format = self.log_format
        check_contained(logs_format, LogsFormat.formats, 'format')

        pattern = DirectoryStructure.pattern_logdir
        dirname = os.path.join(base_dir,
                               substitute(pattern,
                                          id_agent=id_agent,
                                          id_robot=id_robot,
                                          id_stream=id_stream))
        mkdirs_thread_safe(dirname)
        assert os.path.exists(dirname)

        # Add a unique string to the file
        if add_unique:
            tmpfile = tempfile.NamedTemporaryFile(
                                          suffix='.%s.active' % logs_format,
                                          prefix='%s-' % id_stream,
                                          dir=dirname, delete=False)
            tmpfile.write('To be used')

            tmp_filename = tmpfile.name
            warn_good_filename(tmp_filename)
            
            filename = tmp_filename.replace('.active', '')
            tmpfile.close()
        else:
            filename = os.path.join(dirname, '%s.%s' % (id_stream, logs_format)) 
            
            
        # logger.debug('Writing on %r' % friendly_path(filename))

        warn_good_filename(filename)
        

        return filename