当前位置: 首页>>代码示例>>Python>>正文


Python tank.tank_from_path函数代码示例

本文整理汇总了Python中tank.tank_from_path函数的典型用法代码示例。如果您正苦于以下问题:Python tank_from_path函数的具体用法?Python tank_from_path怎么用?Python tank_from_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了tank_from_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_engine_cmd

def run_engine_cmd(log, install_root, pipeline_config_root, context_items, command, using_cwd, args):
    """
    Launches an engine and potentially executes a command.

    :param log: logger
    :param install_root: tank installation
    :param pipeline_config_root: PC config location
    :param context_items: list of strings to describe context. Either ["path"],
                               ["entity_type", "entity_id"] or ["entity_type", "entity_name"]

    :param engine_name: engine to run
    :param command: command to run - None will display a list of commands
    :param using_cwd: Was the context passed based on the current work folder?
    """
    log.debug("")
    log.debug("Context items: %s" % str(context_items))
    log.debug("Command: %s" % command)
    log.debug("Command Arguments: %s" % args)
    log.debug("Code Location Root: %s" % install_root)
    log.debug("Sgtk Pipeline Config Location: %s" % pipeline_config_root)
    log.debug("Location of this script (__file__): %s" % os.path.abspath(__file__))

    log.info("")

    log.info("Welcome to the Shotgun pipeline toolkit!")
    log.info("For documentation, see https://toolkit.shotgunsoftware.com/forums")

    # Now create a tk instance and a context if possible

    if len(context_items) == 1:

        ctx_path = context_items[0]

        if using_cwd:
            log.info("Starting the Sgtk for your current directory '%s'" % ctx_path)

        # context str is a path
        if pipeline_config_root is not None:
            # we are running a project specific tank command
            tk =  tank.tank_from_path(pipeline_config_root)

        else:
            # we are running a studio wide command
            try:
                tk = tank.tank_from_path(ctx_path)
            except TankError, e:
                # this path was not valid. That's ok - we just wont have a tank instance
                # when we run our commands later. This may be if we for example have
                # just run tank setup_project from any random folder
                log.debug("Instantiating Sgtk raised: %s" % e)
                tk = None

        # now try to extract a context
        ctx = None
        if tk is not None:
            ctx = tk.context_from_path(ctx_path)
开发者ID:tonybarbieri,项目名称:tk-core,代码行数:56,代码来源:tank_cmd.py

示例2: refresh_engine

def refresh_engine(engine_name, prev_context, menu_name):
    """
    refresh the current engine
    """    
    current_engine = tank.platform.current_engine()
    
    # first make sure that the disabled menu is reset, if it exists...
    if pm.menu("ShotgunMenuDisabled", exists=True):
        pm.deleteUI("ShotgunMenuDisabled")
    
    # if the scene opened is actually a file->new, then maintain the current
    # context/engine.
    if pm.sceneName() == "":
        return current_engine

    new_path = pm.sceneName().abspath()
    
    # this file could be in another project altogether, so create a new Tank
    # API instance.
    try:
        tk = tank.tank_from_path(new_path)
    except tank.TankError, e:
        OpenMaya.MGlobal.displayInfo("Shotgun: Engine cannot be started: %s" % e)
        # render menu
        create_tank_disabled_menu(menu_name)
        
        # (AD) - this leaves the engine running - is this correct?        
        return current_engine
开发者ID:framestore,项目名称:tk-maya,代码行数:28,代码来源:engine.py

示例3: __tank_on_save_callback

def __tank_on_save_callback():
    """
    Callback that fires every time a file is saved.
    
    Carefully manage exceptions here so that a bug in Tank never
    interrupts the normal workflows in Nuke.
    """
    # get the new file name
    file_name = nuke.root().name()
    
    try:
        # this file could be in another project altogether, so create a new Tank
        # API instance.
        try:
            tk = tank.tank_from_path(file_name)
        except tank.TankError, e:
            __create_tank_disabled_menu(e)
            return
        
        # try to get current ctx and inherit its values if possible
        curr_ctx = None
        if tank.platform.current_engine():
            curr_ctx = tank.platform.current_engine().context
        
        # and now extract a new context based on the file
        new_ctx = tk.context_from_path(file_name, curr_ctx)
        
        # now restart the engine with the new context
        __engine_refresh(tk, new_ctx)
开发者ID:MikrosAnim,项目名称:tk_nuke,代码行数:29,代码来源:__init__.py

示例4: refresh_engine

def refresh_engine(engine_name, prev_context, menu_name):
    """
    refresh the current engine
    """    
    #import rpdb2;rpdb2.start_embedded_debugger("12345")
    current_engine = tank.platform.current_engine()
    
    # first make sure that the disabled menu is reset, if it exists...
    #if pm.menu("ShotgunMenuDisabled", exists=True):
    #    pm.deleteUI("ShotgunMenuDisabled")
    
    # if the scene opened is actually a file->new, then maintain the current
    # context/engine.
    scene_name  = lxtd.current_scene().filename

    if not scene_name:
        return current_engine

    new_path = scene_name
    
    # this file could be in another project altogether, so create a new Tank
    # API instance.
    try:
        tk = tank.tank_from_path(new_path)
    except tank.TankError, e:
        # render menu
        modoshotgunsupport.add_disabled_menu()
        
        # (AD) - this leaves the engine running - is this correct?        
        return current_engine
开发者ID:Leopardob,项目名称:tk-modo,代码行数:30,代码来源:engine.py

示例5: refresh_engine

def refresh_engine(engine_name, prev_context, menu_name):
    """
    refresh the current engine
    """    
    current_engine = tank.platform.current_engine()
    
    # first make sure that the disabled menu is removed, if it exists...
    menu_was_disabled = remove_sgtk_disabled_menu()
    
    # determine the tk instance and ctx to use:
    tk = current_engine.sgtk
    ctx = prev_context
    if pm.sceneName() == "":
        # if the scene opened is actually a file->new, then maintain the current
        # context/engine.
        if not menu_was_disabled:
            # just return the current engine - no need to restart it!
            return current_engine
    else:
        # loading a scene file
        new_path = pm.sceneName().abspath()
    
        # this file could be in another project altogether, so create a new
        # API instance.
        try:
            tk = tank.tank_from_path(new_path)
        except tank.TankError, e:
            OpenMaya.MGlobal.displayInfo("Shotgun: Engine cannot be started: %s" % e)
            # build disabled menu
            create_sgtk_disabled_menu(menu_name)
            return current_engine

        # and construct the new context for this path:
        ctx = tk.context_from_path(new_path, prev_context)
开发者ID:thirstydevil,项目名称:tk-maya,代码行数:34,代码来源:engine.py

示例6: test_from_path

    def test_from_path(self):
        """
        Ensures tank_from_path will resolve site wide configs.
        """
        os.environ["TANK_CURRENT_PC"] = self.pipeline_config_root
        try:
            result = tank.tank_from_path(self.project_root)
            self.assertEqual(result.project_path, self.project_root)
            self.assertEqual(result.pipeline_configuration.get_path(), self.pipeline_config_root)

            self._invalidate_pipeline_configuration_yml()
            with self.assertRaisesRegex(
                TankInitError,
                "however that is not associated with the pipeline configuration"
            ):
                tank.tank_from_path(self.project_root)
        finally:
            del os.environ["TANK_CURRENT_PC"]
开发者ID:shotgunsoftware,项目名称:tk-core,代码行数:18,代码来源:test_pipelineconfig_factory.py

示例7: test_primary_branch

 def test_primary_branch(self):
     """
     Test path from primary branch.
     """
     child_path = os.path.join(self.project_root, "child_dir")
     os.mkdir(os.path.join(self.project_root, "child_dir"))
     result = tank.tank_from_path(child_path)
     self.assertIsInstance(result, Tank)
     self.assertEquals(result.project_path, self.project_root)
开发者ID:hongloull,项目名称:tk-core,代码行数:9,代码来源:test_api.py

示例8: test_alternate_branch

 def test_alternate_branch(self):
     """
     Test path not from primary branch.
     """
     os.mkdir(os.path.join(self.alt_root_1, "child_dir"))
     child_path = os.path.join(self.alt_root_1, "child_dir")
     result = tank.tank_from_path(child_path)
     self.assertIsInstance(result, Tank)
     self.assertEquals(result.project_path, self.project_root)
开发者ID:hongloull,项目名称:tk-core,代码行数:9,代码来源:test_api.py

示例9: getTankEntity

def getTankEntity(projPath):
    '''
    Build a tank instance from project path

    :Params:
        projPath: str
            The path of project that tank defined

    :Returns: 
        a tank instance
    '''
    return tank.tank_from_path(projPath)
开发者ID:chuckbruno,项目名称:dailyworkSubmit,代码行数:12,代码来源:tank_for_of.py

示例10: __get_nuke_path

    def __get_nuke_path(self):

        # Get the shotgun paths.yml file
        current_engine = sgtk.platform.current_engine()
        context = current_engine.context
        tk = tank.tank_from_path(context.tank.roots["primary"])
        config_path = tk.pipeline_configuration.get_path() + "\\config\\env\\includes\\paths.yml"

        # use yaml to extract the path location
        with open(config_path, 'r') as yml_config_file:
            config_file = yaml.load(yml_config_file)

        nuke_path = config_file["nuke_windows"]
        return nuke_path
开发者ID:mds-dev,项目名称:mds_dev,代码行数:14,代码来源:secondary_publish_tk-maya.py

示例11: __tank_startup_node_callback

def __tank_startup_node_callback():    
    """
    Callback that fires every time a node gets created.
    
    Carefully manage exceptions here so that a bug in Tank never
    interrupts the normal workflows in Nuke.    
    """    
    try:
        # look for the root node - this is created only when a new or existing file is opened.
        tn = nuke.thisNode()
        if tn != nuke.root():
            return
            
        if nuke.root().name() == "Root":
            # file->new
            # base it on the context we 'inherited' from the prev session
            # get the context from the previous session - this is helpful if user does file->new
            project_root = os.environ.get("TANK_NUKE_ENGINE_INIT_PROJECT_ROOT")
            tk = tank.Tank(project_root)
            
            ctx_str = os.environ.get("TANK_NUKE_ENGINE_INIT_CONTEXT")
            if ctx_str:
                try:
                    new_ctx = tank.context.deserialize(ctx_str)
                except:
                    new_ctx = tk.context_empty()
            else:
                new_ctx = tk.context_empty()
    
        else:
            # file->open
            file_name = nuke.root().name()
            
            try:
                tk = tank.tank_from_path(file_name)
            except tank.TankError, e:
                __create_tank_disabled_menu(e)
                return
                
            # try to get current ctx and inherit its values if possible
            curr_ctx = None
            if tank.platform.current_engine():
                curr_ctx = tank.platform.current_engine().context                
                
            new_ctx = tk.context_from_path(file_name, curr_ctx)
    
        # now restart the engine with the new context
        __engine_refresh(tk, new_ctx)
开发者ID:MikrosAnim,项目名称:tk_nuke,代码行数:48,代码来源:__init__.py

示例12: __group_yeti_nodes

    def __group_yeti_nodes(self, yetinodes):
        # define the group from the current shotgun ass
        scene_name = cmds.file(query=True, sn=True)
        tk = tank.tank_from_path(scene_name)
        templ = tk.template_from_path(scene_name)
        fields = templ.get_fields(scene_name)

        group_name = fields['Asset'] + "_yetiFurNodes_v" + str(fields['version']).zfill(3)

        # select the top group yeti nodes to maintain hierarchy
        nodes = []
        for i in yetinodes:
            p = cmds.listRelatives(i, parent=True, fullPath=True)
            nodes.append(p[0].split('|')[1])

        cmds.select(nodes)
        return cmds.group(cmds.ls(sl=True), name=group_name, relative=True)
开发者ID:mds-dev,项目名称:mds_dev,代码行数:17,代码来源:secondary_publish_tk-maya-yeti_fur.py

示例13: shotgun_run_action

def shotgun_run_action(log, install_root, pipeline_config_root, is_localized, args):
    """
    Executes the special shotgun run action command from inside of shotgun
    """

    # we are talking to shotgun! First of all, make sure we switch on our html style logging
    log.handlers[0].formatter.enable_html_mode()

    log.debug("Running shotgun_run_action command")
    log.debug("Arguments passed: %s" % args)

    try:
        tk = tank.tank_from_path(pipeline_config_root)
        # attach our logger to the tank instance
        # this will be detected by the shotgun and shell engines
        # and used.
        tk.log = log
    except TankError, e:
        raise TankError("Could not instantiate an Sgtk API Object! Details: %s" % e )
开发者ID:Pixomondo,项目名称:tk-core,代码行数:19,代码来源:tank_cmd.py

示例14: get_idA

def get_idA(objA=[]):
    """
    Store asset ids
    :return:
    """

    assetID_A = []

    for x in objA:
        ass_path = cmds.getAttr(x + '.definition')

        tk_ref = tank.tank_from_path(ass_path)
        context_ref = tk_ref.context_from_path(ass_path)

        if context_ref:
            if context_ref.entity:
                if context_ref.entity.get('id'):
                    assetID_A.append(int(context_ref.entity.get('id')))

    return assetID_A
开发者ID:kidintwo3,项目名称:Alembic-exporter,代码行数:20,代码来源:maya_to_clairsse_alembic.py

示例15: _get_context_from_script

    def _get_context_from_script(self, script):
        """
        Returns an sgtk.context.Context object from the given script path.

        :param script:  The path to a script file on disk.
        """
        tk = tank.tank_from_path(script)

        context = tk.context_from_path(
            script,
            previous_context=self.engine.context,
        )

        if context.project is None:
            raise tank.TankError(
                "The Nuke engine needs at least a project "
                "context in order to start! Your context: %s" % context
            )
        else:
            return context
开发者ID:shotgunsoftware,项目名称:tk-nuke,代码行数:20,代码来源:context.py


注:本文中的tank.tank_from_path函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。