Ejemplo n.º 1
0
from tank.descriptor.errors import TankDescriptorError
from tank.bootstrap import constants as bootstrap_constants
import functools

from utils import (
    cache_apps,
    authenticate,
    add_authentication_options,
    OptionParserLineBreakingEpilog,
    cleanup_bundle_cache,
    wipe_folder,
    automated_setup_documentation,
)

# Set up logging
logger = LogManager.get_logger("bake_config")

# The folder where all items will be cached
BUNDLE_CACHE_ROOT_FOLDER_NAME = "bundle_cache"


def _should_skip(types, desc):
    """
    Check if a descriptor should be skipped.

    :param list types: List of descriptor type names that should be skipped.
    :param dict desc: Descriptor dictionary to check.

    :returns: ``True`` if the contents should be skipped, ``False`` otherwise.
    """
    return desc["type"] in types
Ejemplo n.º 2
0
python_folder = os.path.abspath(os.path.join(this_folder, "..", "python"))
sys.path.append(python_folder)

# sgtk imports
from tank import LogManager
from tank.util import filesystem
from tank.errors import TankError
from tank.platform import environment
from tank.descriptor import Descriptor, descriptor_uri_to_dict, descriptor_dict_to_uri, create_descriptor
from tank.authentication import ShotgunAuthenticator
from tank.bootstrap.baked_configuration import BakedConfiguration
from tank.bootstrap import constants as bootstrap_constants
from tank_vendor import yaml

# set up logging
logger = LogManager.get_logger("build_plugin")

# required keys in the info.yml plugin manifest file
REQUIRED_MANIFEST_PARAMETERS = ["base_configuration", "plugin_id"]

# the folder where all items will be cached
BUNDLE_CACHE_ROOT_FOLDER_NAME = "bundle_cache"

# when we are baking a config, use these settings
BAKED_BUNDLE_NAME = "tk-config-plugin"
BAKED_BUNDLE_VERSION = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")

# generation of the build syntax
BUILD_GENERATION = 2

Ejemplo n.º 3
0
import shutil
import contextlib
import logging

from mock import Mock

from tank_test.tank_test_base import TankTestBase, temp_env_var
from tank_test.tank_test_base import setUpModule  # noqa

from tank import path_cache
from tank import folder
from tank import constants
from tank import LogManager
import tank

log = LogManager.get_logger(__name__)


def add_item_to_cache(path_cache, entity, path, primary=True):
    data = [{
        "entity": entity,
        "path": path,
        "primary": primary,
        "metadata": {}
    }]
    # Last two parameters are only used for debug logging, they can be empty.
    path_cache.add_mappings(data, None, [])


def sync_path_cache(tk, force_full_sync=False):
    """
Ejemplo n.º 4
0
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

import os
import glob
import shutil
import stat

from tank.util import filesystem
from tank.platform import environment
from tank.descriptor import Descriptor, create_descriptor

from tank import LogManager

logger = LogManager.get_logger("utils.caching")


def _cache_descriptor(sg, desc_type, desc_dict, target_path):
    """
    Cache the given descriptor into a new bundle cache.

    :param sg: Shotgun API instance
    :param desc_type: Descriptor.ENGINE | Descriptor.APP | Descriptor.FRAMEWORK
    :param desc_dict: descriptor dict or uri
    :param target_path: bundle cache root to cache into
    """
    desc = create_descriptor(sg, desc_type, desc_dict, fallback_roots=[target_path])
    desc.ensure_local()
    desc_size_kb = filesystem.compute_folder_size(desc.get_path()) / 1024
    logger.info("Caching %s into plugin bundle cache (size %d KiB)" % (desc, desc_size_kb))
Ejemplo n.º 5
0
python_folder = os.path.abspath(os.path.join(this_folder, "..", "python"))
sys.path.append(python_folder)

# sgtk imports
from tank import LogManager
from tank.util import filesystem
from tank.errors import TankError
from tank.platform import environment
from tank.descriptor import Descriptor, descriptor_uri_to_dict, descriptor_dict_to_uri, create_descriptor
from tank.authentication import ShotgunAuthenticator
from tank.bootstrap.baked_configuration import BakedConfiguration
from tank.bootstrap import constants as bootstrap_constants
from tank_vendor import yaml

# set up logging
logger = LogManager.get_logger("build_plugin")

# required keys in the info.yml plugin manifest file
REQUIRED_MANIFEST_PARAMETERS = ["base_configuration", "plugin_id"]

# the folder where all items will be cached
BUNDLE_CACHE_ROOT_FOLDER_NAME = "bundle_cache"

# when we are baking a config, use these settings
BAKED_BUNDLE_NAME = "tk-config-plugin"
BAKED_BUNDLE_VERSION = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")

# generation of the build syntax
BUILD_GENERATION = 2

class OptionParserLineBreakingEpilog(optparse.OptionParser):
Ejemplo n.º 6
0
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

import optparse
import os

from tank import LogManager
from tank.authentication import ShotgunAuthenticator


logger = LogManager.get_logger("utils.authentication")

automated_setup_documentation = """For automated build setups, you can provide a specific shotgun API script name and
and corresponding script key:

> python populate_bundle_cache.py
            --shotgun-host='https://mysite.shotgunstudio.com'
            --shotgun-script-name='plugin_build'
            --shotgun-script-key='<script-key-here>'
            "sgtk:descriptor:app_store?version=v0.3.6&name=tk-config-basic" /tmp

You can also use the SHOTGUN_HOST, SHOTGUN_SCRIPT_NAME and SHOTGUN_SCRIPT_KEY environment
variables to authenticate."""


def add_authentication_options(parser):
Ejemplo n.º 7
0
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

import optparse
import os

from tank import LogManager
from tank.authentication import ShotgunAuthenticator


logger = LogManager.get_logger("utils.authentication")

automated_setup_documentation = """For automated build setups, you can provide a specific shotgun API script name and
and corresponding script key:

> python populate_bundle_cache.py
            --shotgun-host='https://mysite.shotgunstudio.com'
            --shotgun-script-name='plugin_build'
            --shotgun-script-key='<script-key-here>'
            "sgtk:descriptor:app_store?version=v0.3.6&name=tk-config-basic" /tmp

You can also use the SHOTGUN_HOST, SHOTGUN_SCRIPT_NAME and SHOTGUN_SCRIPT_KEY environment
variables to authenticate."""


def add_authentication_options(parser):
Ejemplo n.º 8
0
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

import os
import glob
import shutil
import stat

from tank.util import filesystem
from tank.platform import environment
from tank.descriptor import Descriptor, create_descriptor

from tank import LogManager

logger = LogManager.get_logger("utils.caching")


def _cache_descriptor(sg, desc_type, desc_dict, target_path):
    """
    Cache the given descriptor into a new bundle cache.

    :param sg: Shotgun API instance
    :param desc_type: Descriptor.ENGINE | Descriptor.APP | Descriptor.FRAMEWORK
    :param desc_dict: descriptor dict or uri
    :param target_path: bundle cache root to cache into
    """
    desc = create_descriptor(sg,
                             desc_type,
                             desc_dict,
                             fallback_roots=[target_path])