Exemple #1
0
    def post(self, task_id):
        (name, mode, description, comment, person_id, software_id, revision,
         sep) = self.get_arguments()

        try:
            task = tasks_service.get_task(task_id)
            user_service.check_project_access(task["project_id"])
            software = files_service.get_software(software_id)
            tasks_service.assign_task(task_id,
                                      persons_service.get_current_user()["id"])

            if revision == 0:
                revision = files_service.get_next_working_revision(
                    task_id, name)

            path = self.build_path(task, name, revision, software, sep, mode)

            working_file = files_service.create_new_working_revision(
                task_id,
                person_id,
                software_id,
                name=name,
                path=path,
                comment=comment,
                revision=revision)
        except EntryAlreadyExistsException:
            return {"error": "The given working file already exists."}, 400

        return working_file, 201
Exemple #2
0
 def get_next_working_revision(self):
     self.generate_fixture_working_file(name="main", revision=2)
     self.generate_fixture_working_file(name="main", revision=3)
     self.generate_fixture_working_file(name="main", revision=4)
     self.generate_fixture_working_file(name="main", revision=5)
     revision = files_service.get_next_working_revision(self.task.id, "main")
     self.assertEqual(revision)
Exemple #3
0
    def post(self, task_id):
        person_id = self.get_arguments()
        gunicorn_logger.log(logging.ERROR, task_id)
        gunicorn_logger.log(logging.ERROR, person_id)
        task = tasks_service.get_task(task_id)

        working_file_name = re.sub(
            r'_v\d\d\d.\w\w\w', '',
            file_tree_service.get_working_file_name(task))
        gunicorn_logger.log(logging.ERROR, working_file_name)
        next_revision = files_service.get_next_working_revision(
            task_id, working_file_name)
        working_file_path = file_tree_service.get_working_file_path(
            task, mode="working", revision=next_revision)
        working_file = files_service.create_new_working_revision(
            task_id, person_id, "edfd3a91-4d55-47a4-ae15-f2123c07edf6",
            working_file_name, working_file_path)
        comment = tasks_service.create_comment(
            task_id, '4f4256d0-72d9-4de5-bf71-a08209b56750', person_id,
            "Version %s created" % next_revision)
        preview_file = tasks_service.add_preview_file_to_comment(
            comment['id'], person_id, task_id, revision=next_revision)
        entities_service.update_entity_preview(task['entity_id'],
                                               preview_file['id'])

        output_preview_file_path = file_tree_service.get_working_file_path(
            task, mode="preview_output", revision=next_revision)
        output_slated_file_path = file_tree_service.get_working_file_path(
            task, mode="slated_output", revision=next_revision, frame="0001")

        movies_preview_file_path = '/opt/zou/previews/movies/previews/' + preview_file[
            'id'][:3] + '/' + preview_file['id'][3:6] + '/'
        pictures_original_file_path = '/opt/zou/previews/pictures/originals/' + preview_file[
            'id'][:3] + '/' + preview_file['id'][3:6] + '/'
        pictures_preview_file_path = '/opt/zou/previews/pictures/previews/' + preview_file[
            'id'][:3] + '/' + preview_file['id'][3:6] + '/'
        pictures_thumbnail_file_path = '/opt/zou/previews/pictures/thumbnails/' + preview_file[
            'id'][:3] + '/' + preview_file['id'][3:6] + '/'

        if not os.path.exists(movies_preview_file_path):
            os.makedirs(movies_preview_file_path)
        if not os.path.exists(pictures_original_file_path):
            os.makedirs(pictures_original_file_path)
        if not os.path.exists(pictures_preview_file_path):
            os.makedirs(pictures_preview_file_path)
        if not os.path.exists(pictures_thumbnail_file_path):
            os.makedirs(pictures_thumbnail_file_path)

        if not os.path.exists(os.path.dirname(working_file_path)):
            os.makedirs(os.path.dirname(working_file_path))
        file = open(working_file_path, "w")
        file.close()

        os.symlink(output_preview_file_path,
                   movies_preview_file_path + preview_file['id'])
        os.symlink(output_slated_file_path,
                   pictures_original_file_path + preview_file['id'])
        os.symlink(output_slated_file_path,
                   pictures_preview_file_path + preview_file['id'])
        os.symlink(output_slated_file_path,
                   pictures_thumbnail_file_path + preview_file['id'])

        return working_file, 200