示例#1
0
文件: models.py 项目: yiiwood/ltr
 def get_content_filename(self, filename):
     """Creates filename for file being saved to disk."""
     if self.user is not None:
         username = self.user.username
     else:
         username = '******'
     path = os.path.join(username, 'data')
     ensure_path_exists(settings.MEDIA_ROOT + path)
     return get_unique_filename(os.path.join(path, filename))
示例#2
0
文件: models.py 项目: dangweili/ltr
 def get_content_filename(self, filename):
     """Creates filename for file being saved to disk."""
     if self.user is not None:
         username = self.user.username
     else:
         username = "******"
     path = os.path.join(username, "data")
     ensure_path_exists(settings.MEDIA_ROOT + path)
     return get_unique_filename(os.path.join(path, filename))
示例#3
0
文件: models.py 项目: dangweili/ltr
    def create(solution, launchable_name):
        """Creates a Task instance."""
        task = Task()
        task.solution = solution
        task.working_dir = get_unique_filename(settings.MEDIA_ROOT + "/".join([task.solution.user.username, "task"]))

        ensure_path_exists(task.working_dir)
        task.config_filename = get_unique_filename(task.working_dir + "/config.xml")
        task.log_filename = get_unique_filename(task.working_dir + "/log.txt")
        file_config = open(task.config_filename, "w")
        file_config.write(task.make_config(launchable_name))
        file_config.close()
        task.report_filename = get_unique_filename(task.working_dir + "/report.html")
        open(task.report_filename, "w").close()
        task.is_complete = False
        task.save()
        return task
示例#4
0
文件: models.py 项目: yiiwood/ltr
    def create(solution, launchable_name):
        """Creates a Task instance."""
        task = Task()
        task.solution = solution
        task.working_dir = get_unique_filename(
            settings.MEDIA_ROOT +
            '/'.join([task.solution.user.username, 'task']))

        ensure_path_exists(task.working_dir)
        task.config_filename = get_unique_filename(task.working_dir +
                                                   '/config.xml')
        task.log_filename = get_unique_filename(task.working_dir + '/log.txt')
        file_config = open(task.config_filename, "w")
        file_config.write(task.make_config(launchable_name))
        file_config.close()
        task.report_filename = get_unique_filename(
            task.working_dir + '/report.html')
        open(task.report_filename, 'w').close()
        task.is_complete = False
        task.save()
        return task