def test_from_shot(self):
     """
     Test from shot
     """
     result = tank.tank_from_entity("Shot", self.shot["id"])
     self.assertIsInstance(result, Tank)
     self.assertEquals(result.project_path, self.project_root)
     self.assertEquals(result.pipeline_configuration.get_shotgun_id(), self.sg_pc_entity["id"])
 def test_from_shot(self):
     """
     Test from shot
     """
     result = tank.tank_from_entity("Shot", self.shot["id"])
     self.assertIsInstance(result, Tank)
     self.assertEqual(result.project_path, self.project_root)
     self.assertEqual(result.pipeline_configuration.get_shotgun_id(), self.sg_pc_entity["id"])
    def test_from_entity(self):
        """
        Ensures tank_from_entity will resolve site wide configs.
        """
        os.environ["TANK_CURRENT_PC"] = self.pipeline_config_root
        try:
            result = tank.tank_from_entity("Project", self.project["id"])
            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_entity("Project", self.project["id"])
        finally:
            del os.environ["TANK_CURRENT_PC"]
    def test_from_entity(self):
        """
        Ensures tank_from_entity will resolve site wide configs.
        """
        os.environ["TANK_CURRENT_PC"] = self.pipeline_config_root
        try:
            result = tank.tank_from_entity("Project", self.project["id"])
            self.assertEquals(result.project_path, self.project_root)
            self.assertEquals(result.pipeline_configuration.get_path(), self.pipeline_config_root)

            self._invalidate_pipeline_configuration_yml()
            with self.assertRaisesRegexp(
                TankInitError,
                "however that is not associated with the pipeline configuration"
            ):
                tank.tank_from_entity("Project", self.project["id"])
        finally:
            del os.environ["TANK_CURRENT_PC"]
Example #5
0
 def test_from_entity(self):
     """
     Ensures tank_from_entity will resolve site wide configs.
     """
     os.environ["TANK_CURRENT_PC"] = self.pipeline_config_root
     try:
         result = tank.tank_from_entity("Project", self.project["id"])
         self.assertEquals(result.project_path, self.project_root)
         self.assertEquals(result.pipeline_configuration.get_path(),
                           self.pipeline_config_root)
     finally:
         del os.environ["TANK_CURRENT_PC"]
Example #6
0
    def getServerDirForTankProject(self):
        '''
        get server dir for project which id greater than 300, use Tank template has been defined in templates.yml
        '''
#        projConfigPath = '%s/%s'%(self.tankPath, self.project.tankName).replace('\\', '/')
#        tk = sgtk.sgtk_from_path(projConfigPath)
        taskId = self.task.id
        tk = tank.tank_from_entity('Task', taskId)
        context = tk.context_from_entity('Task', taskId)
        tk.create_filesystem_structure('Task', taskId)
        tmlName = config.reviewTemplate.get(self.entity['type'], None)
        if tmlName:
            tml = tk.templates[tmlName]
            fields = context.as_template_fields(tml)
            return '%s/%s'%(tml.parent.apply_fields(fields), datetime.datetime.today().date().strftime('%Y_%m_%d'))
        raise Exception("Cannot get the review template for %s"%self.entity['type'])
Example #7
0
    def test_archived(self):
        """
        Tests that archived projects are not visible
        """
        self.assertRaisesRegexp(
            TankInitError,
            "No pipeline configurations associated with Project %s" %
            self.project["id"], sgtk.sgtk_from_entity, "Project",
            self.project["id"])

        # now unarchive it
        self.mockgun.update("Project", self.project["id"], {"archived": False})

        result = tank.tank_from_entity("Project", self.project["id"])
        self.assertIsInstance(result, Tank)
        self.assertEquals(result.project_path, self.project_root)
        self.assertEquals(result.pipeline_configuration.get_shotgun_id(),
                          self.sg_pc_entity["id"])
    def test_archived(self):
        """
        Tests that archived projects are not visible
        """
        self.assertRaisesRegex(
            TankInitError,
            "No pipeline configurations associated with Project %s" % self.project["id"],
            sgtk.sgtk_from_entity,
            "Project",
            self.project["id"]
        )

        # now unarchive it
        self.mockgun.update("Project", self.project["id"], {"archived": False})

        result = tank.tank_from_entity("Project", self.project["id"])
        self.assertIsInstance(result, Tank)
        self.assertEqual(result.project_path, self.project_root)
        self.assertEqual(result.pipeline_configuration.get_shotgun_id(), self.sg_pc_entity["id"])
Example #9
0
                tk = None

        # now try to extract a context
        ctx = None
        if tk is not None:
            ctx = tk.context_from_path(ctx_path)

    elif context_items[1].isdigit():

        # shotgun entity type and entity id!
        entity_type = context_items[0]
        entity_id = int(context_items[1])

        # note - tank from path method will validate that we are launching
        # from the right tank command etc.
        tk = tank.tank_from_entity(entity_type, entity_id)

        ctx = tk.context_from_entity(entity_type, entity_id)

    elif pipeline_config_root is not None:

        # shotgun entity type and entity name and we are running a local tank command
        tk = tank.tank_from_path(pipeline_config_root)

        # now parse and resolve the entity name string
        entity_type = context_items[0]
        entity_search_token = context_items[1]
        project_id = tk.pipeline_configuration.get_project_id()
        entity_id = _resolve_shotgun_entity(log, entity_type,
                                            entity_search_token, project_id)
        ctx = tk.context_from_entity(entity_type, entity_id)
Example #10
0
                tk = None

        # now try to extract a context
        ctx = None
        if tk is not None:
            ctx = tk.context_from_path(ctx_path)

    elif context_items[1].isdigit():

        # shotgun entity type and entity id!
        entity_type = context_items[0]
        entity_id = int(context_items[1])

        # note - tank from path method will validate that we are launching
        # from the right tank command etc.
        tk = tank.tank_from_entity(entity_type, entity_id)

        ctx = tk.context_from_entity(entity_type, entity_id)

    elif pipeline_config_root is not None:

        # shotgun entity type and entity name and we are running a local tank command
        tk =  tank.tank_from_path(pipeline_config_root)

        # now parse and resolve the entity name string
        entity_type = context_items[0]
        entity_search_token = context_items[1]
        project_id = tk.pipeline_configuration.get_project_id()
        entity_id = _resolve_shotgun_entity(log, entity_type, entity_search_token, project_id)
        ctx = tk.context_from_entity(entity_type, entity_id)