Exemplo n.º 1
0
    def test_create_new_working_revision(self):
        self.working_file.delete()
        working_file = files_service.create_new_working_revision(
            self.task.id,
            self.person.id,
            self.software.id,
            "main",
            "/path"
        )
        self.assertEqual(working_file["revision"], 1)
        working_files = files_service.get_working_files_for_task(self.task.id)
        working_file = files_service.create_new_working_revision(
            self.task.id,
            self.person.id,
            self.software.id,
            "main",
            "/path"
        )
        working_files = files_service.get_working_files_for_task(self.task.id)
        self.assertEqual(working_file["revision"], 2)
        self.assertEqual(len(working_files), 2)

        with pytest.raises(EntryAlreadyExistsException):
            working_file = files_service.create_new_working_revision(
                self.task.id,
                self.person.id,
                self.software.id,
                "main",
                "/path",
                revision=2
            )
Exemplo n.º 2
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
Exemplo n.º 3
0
    def post(self, entity_id):
        (name, path, mode, description, comment, person_id, software_id,
         revision, sep, size) = self.get_arguments()
        task_id = None

        # try by task
        try:
            task = tasks_service.get_task(entity_id)
            task_id = entity_id
            entity_id = task["entity_id"]
            user_service.check_project_access(task["project_id"])
            user_service.check_entity_access(task["entity_id"])
            tasks_service.assign_task(task_id,
                                      persons_service.get_current_user()["id"])
        except:
            # try by entity
            entity = entities_service.get_entity(entity_id)
            user_service.check_project_access(entity["project_id"])
            user_service.check_entity_access(entity_id)

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

        return working_file, 201
Exemplo n.º 4
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