Exemplo n.º 1
0
    def post_app_init(self):
        """
        Initialization that runs after all apps and the QT abstractions have been loaded.
        """
        from sgtk import LogManager

        LogManager().global_debug = True
Exemplo n.º 2
0
 def __init__(self):
     self._logger = LogManager.get_logger(__name__)
     # Only log debug messages if they are specifically requested.
     if self._is_debugging_rpc():
         self._simple_thread_ids = {}
         self._id_generation_lock = threading.Lock()
         self._logger.setLevel(logging.DEBUG)
     else:
         self._logger.setLevel(logging.INFO)
Exemplo n.º 3
0
def init_logging():
    """
    Initialize logging
    """
    global logger, formatter

    # set up std toolkit logging to file
    LogManager().initialize_base_file_handler(app_name)

    # set up output of all sgtk log messages to stdout
    handler = logging.StreamHandler(sys.stdout)
    LogManager().initialize_custom_handler(handler)

    # check if there is a --debug flag anywhere in the args list.
    # in that case turn on debug logging and remove the flag
    if os.environ.get("DD_DEBUG"):
        LogManager().global_debug = True
        logger.debug("")
        logger.debug("A log file can be found in %s" % LogManager().log_folder)
        logger.debug("")

    logger.debug("Running main from %s" % __file__)
    return handler
Exemplo n.º 4
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.
"""
Implements communication channels between the desktop app and the background process.
"""

from .rpc import RPCServerThread, RPCProxy

from sgtk import LogManager

logger = LogManager.get_logger(__name__)


class CommunicationBase(object):
    """
    Communication channel base class.
    """
    def __init__(self, engine):
        """
        :param engine: Toolkit engine.
        """
        self._engine = engine
        self._msg_server = None
        self._proxy = None

    @property
#
# 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.

"""
Implements communication channels between the desktop app and the background process.
"""

from .rpc import RPCServerThread, RPCProxy

from sgtk import LogManager

logger = LogManager.get_logger(__name__)


class CommunicationBase(object):
    """
    Communication channel base class.
    """

    def __init__(self, engine):
        """
        :param engine: Toolkit engine.
        """
        self._engine = engine
        self._msg_server = None
        self._proxy = None
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
# add sgtk API
this_folder = os.path.abspath(os.path.dirname(__file__))
python_folder = os.path.abspath(os.path.join(this_folder, "..", "python"))
sys.path.append(python_folder)

# sgtk imports
from sgtk import LogManager
from sgtk.util import filesystem
from sgtk.descriptor import Descriptor, create_descriptor, is_descriptor_version_missing

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

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

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


def _build_bundle_cache(sg_connection, target_path, config_descriptor_uri):
    """
    Perform a build of the bundle cache.

    This will build the bundle cache for a given config descriptor.

    :param sg_connection: Shotgun connection
    :param target_path: Path to build
    :param config_descriptor_uri: Descriptor of the configuration to cache.
    """
Exemplo n.º 8
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 sys

import sgtk
import traceback
from sgtk.platform import Engine
from sgtk import LogManager

logger = LogManager.get_logger(__file__)

previous_except_hook = sys.excepthook


def unhandled_exception_handler(exc_type, exc_value, exc_traceback):
    """
    Unhandled exception handler.

    When this file gets loaded, we ensure that both the site desktop and project
    desktop will see any unexpected errors be logged to disk and in the GUI.

    This sort of error typically happens when an error is thrown from a Qt
    application's slot and doesn't get handled.
    """
    # Calls any previous exception handler. By default, this will invoke the
Exemplo n.º 9
0
#
# 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 sys, os, logging

import sgtk
from sgtk import constants
from sgtk import LogManager

# the logger used by this file is sgtk.tank_cmd
app_name = "shotgun_publish"
logger = LogManager.get_logger(app_name)


def init_logging():
    """
    Initialize logging
    """
    global logger, formatter

    # set up std toolkit logging to file
    LogManager().initialize_base_file_handler(app_name)

    # set up output of all sgtk log messages to stdout
    handler = logging.StreamHandler(sys.stdout)
    LogManager().initialize_custom_handler(handler)
Exemplo n.º 10
0
# add sgtk API
this_folder = os.path.abspath(os.path.dirname(__file__))
python_folder = os.path.abspath(os.path.join(this_folder, "..", "python"))
sys.path.append(python_folder)

# sgtk imports
from sgtk import LogManager
from sgtk.util import filesystem
from sgtk.descriptor import Descriptor, create_descriptor, is_descriptor_version_missing

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

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

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


def _build_bundle_cache(sg_connection, target_path, config_descriptor_uri):
    """
    Perform a build of the bundle cache.

    This will build the bundle cache for a given config descriptor.

    :param sg_connection: Shotgun connection
    :param target_path: Path to build
    :param config_descriptor_uri: Descriptor of the configuration to cache.
    """