Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
 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))
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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