Пример #1
0
def main():
    """
    Main entry point for script.

    Handles argument parsing and validation and then calls the script payload.
    """

    usage = "%prog [options] config_descriptor target_path"

    desc = "Bake a self contained Toolkit config from a descriptor"

    epilog = """

Details and Examples
--------------------

In its simplest form, just provide a local path and target folder for the build.

> python bake_config.py ~/dev/tk-config-myconfig /tmp/baked_configurations

Or you can specify a version with a Toolkit config descriptor uri.

> python bake_config.py "sgtk:descriptor:dev?version=v1.0.9&path=../tk-config-myconfig" /tmp/baked_configurations

Any type of Toolkit config descriptor uri can be used, if a version is not specified, the latest for the descriptor is resolved.

> python bake_config.py "sgtk:descriptor:app_store?name=tk-config-basic" /tmp/baked_configurations

By default, all bundle types are cached. If you want to omit certain types, simply provide a comma seperated list
of bundle types to skip, e.g. --skip-bundle-types=app_store,shotgun,github_release.

{automated_setup_documentation}

For information about the various descriptors that can be used, see
http://developer.shotgridsoftware.com/tk-core/descriptor


""".format(
        automated_setup_documentation=automated_setup_documentation
    ).format(
        script_name="bake_config.py"
    )
    parser = OptionParserLineBreakingEpilog(
        usage=usage, description=desc, epilog=epilog
    )

    parser.add_option(
        "-d", "--debug", default=False, action="store_true", help="Enable debug logging"
    )

    parser.add_option(
        "-z", "--zip", default=False, action="store_true", help="Zip archive the config"
    )

    parser.add_option(
        "--skip-bundle-types",
        # You can't have an empty default optional value, so we'll pick something
        # and treat it accordingly.
        default="none",
        help="Comma separated list of bundle types to skip. Possible values are 'app_store', "
        "'git', 'git_branch', 'github_release', 'shotgun'. Empty by default.",
    )

    add_authentication_options(parser)

    # parse cmd line
    (options, remaining_args) = parser.parse_args()

    logger.info("Welcome to the Toolkit config baker.")
    logger.info("")

    if options.debug:
        LogManager().global_debug = True

    if len(remaining_args) != 2:
        parser.print_help()
        return 2

    # Get config descriptor
    config_descriptor = remaining_args[0]
    # Try to parse it, check if it is a local path if it fails
    try:
        descriptor_uri_to_dict(config_descriptor)
    except TankDescriptorError:
        # Check if it is a local path
        path = os.path.abspath(
            os.path.expanduser(os.path.expandvars(config_descriptor))
        )
        if os.path.isdir(path):
            logger.info("Using a dev descriptor for local path %s" % path)
            # Forge a dev descriptor, using "latest" for the version.
            # TODO: try to retrieve a valid version from the folder, e.g. with a
            # git tag from the folder.
            config_descriptor = "sgtk:descriptor:dev?name=%s&path=%s&version=latest" % (
                os.path.basename(path),
                path,
            )
        else:
            logger.error(
                "%s is not a valid descriptor nor a local path." % config_descriptor
            )
            raise
    # Get output path
    target_path = remaining_args[1]
    target_path = os.path.expanduser(os.path.expandvars(target_path))

    sg_user = authenticate(options)

    sg_connection = sg_user.create_sg_connection()
    # make sure we are properly connected
    try:
        sg_connection.find_one("HumanUser", [])
    except Exception as e:
        logger.error("Could not communicate with ShotGrid: %s" % e)
        return 3

    # Strip any extra whitespaces and make sure every bundle type exists.
    skip_bundle_types = options.skip_bundle_types.split(",")
    skip_bundle_types = [bundle_type.strip() for bundle_type in skip_bundle_types]
    for bundle_type in skip_bundle_types:
        if bundle_type not in [
            "app_store",
            "git",
            "git_branch",
            "github_release",
            "shotgun",
            "none",
        ]:
            logger.error("Unknown bundle type: %s" % bundle_type)
            return 4

    # we are all set.
    bake_config(
        sg_connection, config_descriptor, target_path, options.zip, skip_bundle_types,
    )

    # all good!
    return 0
Пример #2
0
def main():
    """
    Main entry point for script.

    Handles argument parsing and validation and then calls the script payload.
    """

    usage = "%prog [options] config_descriptor target_path"

    desc = "Bake a self contained Toolkit config from a descriptor"

    epilog = """

Details and Examples
--------------------

In its simplest form, just provide a local path and target folder for the build.

> python bake_config.py ~/dev/tk-config-myconfig /tmp/baked_configurations

Or you can specify a version with a Toolkit config descriptor uri.

> python bake_config.py "sgtk:descriptor:dev?version=v1.0.9&path=../tk-config-myconfig" /tmp/baked_configurations

Any type of Toolkit config descriptor uri can be used, if a version is not specified, the latest for the descriptor is resolved.

> python bake_config.py "sgtk:descriptor:app_store?name=tk-config-basic" /tmp/baked_configurations

{automated_setup_documentation}

For information about the various descriptors that can be used, see
http://developer.shotgunsoftware.com/tk-core/descriptor


""".format(automated_setup_documentation=automated_setup_documentation)
    parser = OptionParserLineBreakingEpilog(usage=usage,
                                            description=desc,
                                            epilog=epilog)

    parser.add_option("-d",
                      "--debug",
                      default=False,
                      action="store_true",
                      help="Enable debug logging")

    parser.add_option("-z",
                      "--zip",
                      default=False,
                      action="store_true",
                      help="Zip archive the config")

    parser.add_option("-r",
                      "--sparse",
                      default=False,
                      action="store_true",
                      help="Don't cache any app_store bundles")

    add_authentication_options(parser)

    # parse cmd line
    (options, remaining_args) = parser.parse_args()

    logger.info("Welcome to the Toolkit config baker.")
    logger.info("")

    if options.debug:
        LogManager().global_debug = True

    if len(remaining_args) != 2:
        parser.print_help()
        return 2

    # Get config descriptor
    config_descriptor = remaining_args[0]
    # Try to parse it, check if it is a local path if it fails
    try:
        descriptor_uri_to_dict(config_descriptor)
    except TankDescriptorError as e:
        # Check if it is a local path
        path = os.path.abspath(
            os.path.expanduser(os.path.expandvars(config_descriptor)))
        if os.path.isdir(path):
            logger.info("Using a dev descriptor for local path %s" % path)
            # Forge a dev descriptor, using "latest" for the version.
            # TODO: try to retrieve a valid version from the folder, e.g. with a
            # git tag from the folder.
            config_descriptor = "sgtk:descriptor:dev?name=%s&path=%s&version=latest" % (
                os.path.basename(path), path)
        else:
            logger.error("%s is not a valid descriptor nor a local path." %
                         config_descriptor)
            raise
    # Get output path
    target_path = remaining_args[1]
    target_path = os.path.expanduser(os.path.expandvars(target_path))

    sg_user = authenticate(options)

    sg_connection = sg_user.create_sg_connection()
    # make sure we are properly connected
    try:
        sg_connection.find_one("HumanUser", [])
    except Exception, e:
        logger.error("Could not communicate with Shotgun: %s" % e)
        return 3
Пример #3
0
def main():
    """
    Main entry point for script.

    Handles argument parsing and validation and then calls the script payload.
    """

    usage = "%prog [options] source_path target_path"

    desc = "Builds a standard toolkit plugin structure ready for testing and deploy"

    epilog = """

Details and Examples
--------------------

In its simplest form, just provide a source and target folder for the build.

> python build_plugin.py ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

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

> python build_plugin.py
            --shotgun-host='https://mysite.shotgunstudio.com'
            --shotgun-script-name='plugin_build'
            --shotgun-script-key='<script-key-here>'
            ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

By default, the build script will use the latest app store core for its bootstrapping.
If you want to use a specific core for the bootstrap, this can be specified via the
--bootstrap-core-uri option:

> python build_plugin.py
            --bootstrap-core-uri='sgtk:descriptor:dev?path=~/dev/tk-core'
            ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

For information about the various descriptors that can be used, see
http://developer.shotgunsoftware.com/tk-core/descriptor


"""
    parser = OptionParserLineBreakingEpilog(usage=usage,
                                            description=desc,
                                            epilog=epilog)

    parser.add_option("-d",
                      "--debug",
                      default=False,
                      action="store_true",
                      help="Enable debug logging")

    parser.add_option(
        "-c",
        "--bootstrap-core-uri",
        default=None,
        action="store",
        help=
        ("Specify which version of core to be used by the bootstrap process. "
         "If not specified, defaults to the most recently released core."))

    add_authentication_options(parser)

    # parse cmd line
    (options, remaining_args) = parser.parse_args()

    logger.info("Welcome to the Toolkit plugin builder.")
    logger.info("")

    if options.debug:
        LogManager().global_debug = True

    if options.bootstrap_core_uri:
        bootstrap_core_uri = options.bootstrap_core_uri
    else:
        # default
        bootstrap_core_uri = None

    if len(remaining_args) != 2:
        parser.print_help()
        return 2

    # get paths
    source_path = remaining_args[0]
    target_path = remaining_args[1]

    # convert any env vars and tildes
    source_path = os.path.expanduser(os.path.expandvars(source_path))
    target_path = os.path.expanduser(os.path.expandvars(target_path))

    sg_user = authenticate(options)

    sg_connection = sg_user.create_sg_connection()
    # make sure we are properly connected
    try:
        sg_connection.find_one("HumanUser", [])
    except Exception, e:
        logger.error("Could not communicate with Shotgun: %s" % e)
        return 3
def main():
    """
    Main entry point for script.

    Handles argument parsing and validation and then calls the script payload.
    """

    usage = "%prog [options] config_descriptor target_path"

    desc = "Populates a bundle cache for a given configuration."

    epilog = """

Details and Examples
--------------------

In it's simplest form, provide a descriptor to a configuration and the location
where the bundle cache should be created.

> python populate_bundle_cache.py
            "sgtk:descriptor:app_store?version=v0.3.6&name=tk-config-basic"
            /tmp

Note that it is important to use quotes around the descriptor as shells usually
give special meaning to the & character.

{automated_setup_documentation}

For information about the various descriptors that can be used, see
http://developer.shotgunsoftware.com/tk-core/descriptor


""".format(automated_setup_documentation=automated_setup_documentation)
    parser = OptionParserLineBreakingEpilog(usage=usage,
                                            description=desc,
                                            epilog=epilog)

    parser.add_option("-d",
                      "--debug",
                      default=False,
                      action="store_true",
                      help="Enable debug logging")

    add_authentication_options(parser)

    # parse cmd line
    (options, remaining_args) = parser.parse_args()

    logger.info("Welcome to the Toolkit bundle cache builder.")
    logger.info("")

    if options.debug:
        LogManager().global_debug = True

    if len(remaining_args) != 2:
        parser.print_help()
        return 2

    # get paths
    config_descriptor_str = remaining_args[0]
    target_path = remaining_args[1]

    # convert any env vars and tildes
    target_path = os.path.expanduser(os.path.expandvars(target_path))

    sg_user = authenticate(options)

    sg_connection = sg_user.create_sg_connection()

    # we are all set.
    _build_bundle_cache(sg_connection, target_path, config_descriptor_str)

    # all good!
    return 0
def main():
    """
    Main entry point for script.

    Handles argument parsing and validation and then calls the script payload.
    """

    usage = "%prog [options] source_path target_path"

    desc = "Builds a standard toolkit plugin structure ready for testing and deploy"

    epilog = """

Details and Examples
--------------------

In its simplest form, just provide a source and target folder for the build.

> python build_plugin.py ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

By default, the build script will use the latest app store core for its bootstrapping.
If you want to use a specific core for the bootstrap, this can be specified via the
--bootstrap-core-uri option:

> python build_plugin.py
            --bootstrap-core-uri='sgtk:descriptor:dev?path=~/dev/tk-core'
            ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

By using the '--bake' option, you can build a plugin with an immutable configuration
where every single Toolkit component is cached and frozen to the version retrieved at
build time. This can be useful to distribute a self contained plugin to third party
users.

> python build_plugin.py
            ~/dev/tk-maya/plugins/basic /tmp/maya-plugin
            --bake

{automated_setup_documentation}

For information about the various descriptors that can be used, see
http://developer.shotgunsoftware.com/tk-core/descriptor


""".format(automated_setup_documentation=automated_setup_documentation)
    parser = OptionParserLineBreakingEpilog(usage=usage,
                                            description=desc,
                                            epilog=epilog)

    parser.add_option("-d",
                      "--debug",
                      default=False,
                      action="store_true",
                      help="Enable debug logging")

    parser.add_option(
        "-c",
        "--bootstrap-core-uri",
        default=None,
        action="store",
        help=
        ("Specify which version of core to be used by the bootstrap process. "
         "If not specified, defaults to the most recently released core."))

    parser.add_option("--bake",
                      default=False,
                      action="store_true",
                      help="Bake the plugin with an immutable configuration.")

    parser.add_option(
        "--system-core",
        default=False,
        action="store_true",
        help=
        "Use tk-core installed on the system rather than a private copy in the config."
    )

    add_authentication_options(parser)

    # parse cmd line
    (options, remaining_args) = parser.parse_args()

    logger.info("Welcome to the Toolkit plugin builder.")
    logger.info("")

    if options.debug:
        LogManager().global_debug = True

    if options.system_core:
        if options.bootstrap_core_uri:
            parser.error(
                "bootstrap-core-uri and system-core options are incompatible. "
                "Please use one or the other but not both.")
        if not options.bake:
            parser.error(
                "system-core option can only be used for baked plugins. "
                "Please use the --bake option or do not use --system-core.")

    if options.bootstrap_core_uri:
        bootstrap_core_uri = options.bootstrap_core_uri
    else:
        # default
        bootstrap_core_uri = None

    if len(remaining_args) != 2:
        parser.print_help()
        return 2

    # get paths
    source_path = remaining_args[0]
    target_path = remaining_args[1]

    # convert any env vars and tildes
    source_path = os.path.expanduser(os.path.expandvars(source_path))
    target_path = os.path.expanduser(os.path.expandvars(target_path))

    sg_user = authenticate(options)

    sg_connection = sg_user.create_sg_connection()
    # make sure we are properly connected
    try:
        sg_connection.find_one("HumanUser", [])
    except Exception, e:
        logger.error("Could not communicate with Shotgun: %s" % e)
        return 3
Пример #6
0
def main():
    """
    Main entry point for script.

    Handles argument parsing and validation and then calls the script payload.
    """

    usage = "%prog [options] config_descriptor target_path"

    desc = "Populates a bundle cache for a given configuration."

    epilog = """

Details and Examples
--------------------

In it's simplest form, provide a descriptor to a configuration and the location
where the bundle cache should be created.

> python populate_bundle_cache.py
            "sgtk:descriptor:app_store?version=v0.3.6&name=tk-config-basic"
            /tmp

Note that it is important to use quotes around the descriptor as shells usually
give special meaning to the & character.

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

For information about the various descriptors that can be used, see
http://developer.shotgunsoftware.com/tk-core/descriptor


"""
    parser = OptionParserLineBreakingEpilog(usage=usage, description=desc, epilog=epilog)

    parser.add_option(
        "-d",
        "--debug",
        default=False,
        action="store_true",
        help="Enable debug logging"
    )

    add_authentication_options(parser)

    # parse cmd line
    (options, remaining_args) = parser.parse_args()

    logger.info("Welcome to the Toolkit bundle cache builder.")
    logger.info("")

    if options.debug:
        LogManager().global_debug = True

    if len(remaining_args) != 2:
        parser.print_help()
        return 2

    # get paths
    config_descriptor_str = remaining_args[0]
    target_path = remaining_args[1]

    # convert any env vars and tildes
    target_path = os.path.expanduser(os.path.expandvars(target_path))

    sg_user = authenticate(options)

    sg_connection = sg_user.create_sg_connection()

    # we are all set.
    _build_bundle_cache(
        sg_connection,
        target_path,
        config_descriptor_str
    )

    # all good!
    return 0
Пример #7
0
def main():
    """
    Main entry point for script.

    Handles argument parsing and validation and then calls the script payload.
    """

    usage = "%prog [options] source_path target_path"

    desc = "Builds a standard toolkit plugin structure ready for testing and deploy"

    epilog = """

Details and Examples
--------------------

In its simplest form, just provide a source and target folder for the build.

> python build_plugin.py ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

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

> python build_plugin.py
            --shotgun-host='https://mysite.shotgunstudio.com'
            --shotgun-script-name='plugin_build'
            --shotgun-script-key='<script-key-here>'
            ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

By default, the build script will use the latest app store core for its bootstrapping.
If you want to use a specific core for the bootstrap, this can be specified via the
--bootstrap-core-uri option:

> python build_plugin.py
            --bootstrap-core-uri='sgtk:descriptor:dev?path=~/dev/tk-core'
            ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

For information about the various descriptors that can be used, see
http://developer.shotgunsoftware.com/tk-core/descriptor


"""
    parser = OptionParserLineBreakingEpilog(usage=usage, description=desc, epilog=epilog)

    parser.add_option(
        "-d",
        "--debug",
        default=False,
        action="store_true",
        help="Enable debug logging"
    )

    parser.add_option(
        "-c",
        "--bootstrap-core-uri",
        default=None,
        action="store",
        help=("Specify which version of core to be used by the bootstrap process. "
              "If not specified, defaults to the most recently released core.")
    )

    add_authentication_options(parser)

    # parse cmd line
    (options, remaining_args) = parser.parse_args()

    logger.info("Welcome to the Toolkit plugin builder.")
    logger.info("")

    if options.debug:
        LogManager().global_debug = True

    if options.bootstrap_core_uri:
        bootstrap_core_uri = options.bootstrap_core_uri
    else:
        # default
        bootstrap_core_uri = None

    if len(remaining_args) != 2:
        parser.print_help()
        return 2

    # get paths
    source_path = remaining_args[0]
    target_path = remaining_args[1]

    # convert any env vars and tildes
    source_path = os.path.expanduser(os.path.expandvars(source_path))
    target_path = os.path.expanduser(os.path.expandvars(target_path))

    sg_user = authenticate(options)

    sg_connection = sg_user.create_sg_connection()
    # make sure we are properly connected
    try:
        sg_connection.find_one("HumanUser", [])
    except Exception, e:
        logger.error("Could not communicate with Shotgun: %s" % e)
        return 3
Пример #8
0
def main():
    """
    Main entry point for script.

    Handles argument parsing and validation and then calls the script payload.
    """

    usage = "%prog [options] source_path target_path"

    desc = "Builds a standard toolkit plugin structure ready for testing and deploy"

    epilog = """

Details and Examples
--------------------

In its simplest form, just provide a source and target folder for the build.

> python build_plugin.py ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

By default, the build script will use the latest app store core for its bootstrapping.
If you want to use a specific core for the bootstrap, this can be specified via the
--bootstrap-core-uri option:

> python build_plugin.py
            --bootstrap-core-uri='sgtk:descriptor:dev?path=~/dev/tk-core'
            ~/dev/tk-maya/plugins/basic /tmp/maya-plugin

By using the '--bake' option, you can build a plugin with an immutable configuration
where every single Toolkit component is cached and frozen to the version retrieved at
build time. This can be useful to distribute a self contained plugin to third party
users.

> python build_plugin.py
            ~/dev/tk-maya/plugins/basic /tmp/maya-plugin
            --bake

{automated_setup_documentation}

For information about the various descriptors that can be used, see
http://developer.shotgunsoftware.com/tk-core/descriptor


""".format(automated_setup_documentation=automated_setup_documentation)
    parser = OptionParserLineBreakingEpilog(usage=usage, description=desc, epilog=epilog)

    parser.add_option(
        "-d",
        "--debug",
        default=False,
        action="store_true",
        help="Enable debug logging"
    )

    parser.add_option(
        "-c",
        "--bootstrap-core-uri",
        default=None,
        action="store",
        help=("Specify which version of core to be used by the bootstrap process. "
              "If not specified, defaults to the most recently released core.")
    )

    parser.add_option(
        "--bake",
        default=False,
        action="store_true",
        help="Bake the plugin with an immutable configuration."
    )

    parser.add_option(
        "--system-core",
        default=False,
        action="store_true",
        help="Use tk-core installed on the system rather than a private copy in the config."
    )

    add_authentication_options(parser)

    # parse cmd line
    (options, remaining_args) = parser.parse_args()

    logger.info("Welcome to the Toolkit plugin builder.")
    logger.info("")

    if options.debug:
        LogManager().global_debug = True

    if options.system_core:
        if options.bootstrap_core_uri:
            parser.error(
                "bootstrap-core-uri and system-core options are incompatible. "
                "Please use one or the other but not both."
            )
        if not options.bake:
            parser.error(
                "system-core option can only be used for baked plugins. "
                "Please use the --bake option or do not use --system-core."
            )

    if options.bootstrap_core_uri:
        bootstrap_core_uri = options.bootstrap_core_uri
    else:
        # default
        bootstrap_core_uri = None

    if len(remaining_args) != 2:
        parser.print_help()
        return 2

    # get paths
    source_path = remaining_args[0]
    target_path = remaining_args[1]

    # convert any env vars and tildes
    source_path = os.path.expanduser(os.path.expandvars(source_path))
    target_path = os.path.expanduser(os.path.expandvars(target_path))

    sg_user = authenticate(options)

    sg_connection = sg_user.create_sg_connection()
    # make sure we are properly connected
    try:
        sg_connection.find_one("HumanUser", [])
    except Exception, e:
        logger.error("Could not communicate with Shotgun: %s" % e)
        return 3