@classmethod
    def upload_output(cls, version, output_file_full_path):
        """sets the given file as the output of the given version, also
        generates a thumbnail and a web version if it is a movie file

        :param version: The stalker version instance
        :param output_file_full_path: the path of the media file
        """
        from stalker import Version
        if not isinstance(version, Version):
            raise RuntimeError('version should be a stalker version instance!')

        hires_extension = '.mov'
        webres_extension = '.webm'
        thumbnail_extension = '.png'

        output_file_name = os.path.basename(output_file_full_path)

        hires_output_file_name = '%s%s' % (
            os.path.splitext(output_file_name)[0],
            hires_extension
        )

        webres_output_file_name = '%s%s' % (
            os.path.splitext(output_file_name)[0],
            webres_extension
        )

        thumbnail_output_file_name = '%s%s' % (
            os.path.splitext(output_file_name)[0],
            thumbnail_extension
        )

        task = version.task

        hires_path = os.path.join(
            task.absolute_path, 'Outputs', 'Stalker_Pyramid',
            hires_output_file_name
        )
        webres_path = os.path.join(
            task.absolute_path, 'Outputs', 'Stalker_Pyramid', 'ForWeb',
            webres_output_file_name
        )
        thumbnail_path = os.path.join(
            task.absolute_path, 'Outputs', 'Stalker_Pyramid', 'Thumbnail',
            thumbnail_output_file_name
        )

        # create folders
        try:
            os.makedirs(os.path.dirname(hires_path))
        except OSError:
            pass

        try:
            os.makedirs(os.path.dirname(webres_path))
        except OSError:
            pass

        try:
            os.makedirs(os.path.dirname(thumbnail_path))
        except OSError:
            pass

        shutil.copy(output_file_full_path, hires_path)

        # generate the web version
        from anima.utils import MediaManager
        m = MediaManager()
        temp_web_version_full_path = \
            m.generate_media_for_web(output_file_full_path)

        try:
            shutil.copy(temp_web_version_full_path, webres_path)
        except IOError:
            pass

        temp_thumbnail_full_path = \
            m.generate_thumbnail(output_file_full_path)
        try:
            # also upload thumbnail
            shutil.copy(temp_thumbnail_full_path, thumbnail_path)
        except __HOLE__:
            pass

        project = task.project
        repo = project.repository

        from stalker import db, Link

        # try to find a file with the same name assigned to the version as
        # output
        found = None
        hires_os_independent_path = repo.to_os_independent_path(hires_path)
        for output in version.outputs:
            if output.full_path == hires_os_independent_path:
                found = True
                break

        # if we found a file with the same name as the output, just overwrite
        # it
        if not found:
            l_hires = Link(
                full_path=repo.to_os_independent_path(hires_path),
                original_filename=hires_output_file_name
            )

            l_for_web = Link(
                full_path=repo.to_os_independent_path(webres_path),
                original_filename=hires_output_file_name
            )

            l_hires.thumbnail = l_for_web
            version.outputs.append(l_hires)

            l_thumb = Link(
                full_path=repo.to_os_independent_path(thumbnail_path),
                original_filename=hires_output_file_name
            )
            l_for_web.thumbnail = l_thumb

            db.DBSession.add_all([l_hires, l_for_web, l_thumb])
            db.DBSession.commit()

        return hires_path
dataset/ETHPy150Open eoyilmaz/anima/anima/env/mayaEnv/auxiliary.py/Playblaster.upload_output