Ejemplo n.º 1
0
    def _tank_instance(cls, env, paths, settings):
        """@return the initialized tank package that exists at TANK_STUDIO_INSTALL_TREE, and the context path which created
        the instance
        @param env enviornment of the to-be-started process
        @param paths from which to pull the context. They should be sorted from most specialized to to least 
        specialized
        @param settings matching the tank_engine_schema
        @throws EnvironmentError if we couldn't find it"""
        sgtk = cls._sgtk_module(env)

        if settings.force_tank_from_entity:
            if not (settings.entity_type and settings.entity_id):
                msg = "Was forced to create tank from entity, but didn't get entity information"
                raise AssertionError(msg)
            # end 

            return sgtk.tank_from_entity(settings.entity_type, settings.entity_id), 'context_path_not_set'
        else:
            errors = list()
            for path in paths:
                try:
                    return sgtk.tank_from_path(path), path
                except Exception as err:
                    errors.append(err)
            # end for each path to try
        # end handle tank instantiation mode

        raise EnvironmentError("Failed to initialize tank from any of the given context paths: %s\nErrors: %s" 
                               % (', '.join(paths), '\n'.join(str(err) for err in errors)))
    def launchFromContext(self, entityId):

        appLauncher = self.SGTK_ENGINE.apps[self.launchApp]

        tk_i = sgtk.tank_from_entity("Task", entityId)
        context = tk_i.context_from_entity("Task", self.sgTaskDict['id'])

        print self.launchApp, "launch -> empty ", context
        try:
            print "TASK ", context.task
        except:
            pass
        appLauncher._launch_app(context, version=self.version)
		def setAudioToCorrectPath():
			scenePath = cmds.file(q=True,sceneName=True)
			scene_template = tk.template_from_path(scenePath)
			flds = scene_template.get_fields(scenePath)
			audio_template = tk.templates["shot_published_audio"]

			tank = sgtk.tank_from_entity('Project', 66)

			allShots = cmds.ls(type="shot")
			allAudio = cmds.ls(type="audio")
			reportList = []
			returnList = []
			for seqShot in allShots:
				audio = cmds.shot(seqShot,q=True,audio=True)
				audioFile = cmds.getAttr(audio+".filename")# "W:/RTS/1_PREPROD/13_ANIMATIC/q340/splitshots/wav new 01/q340_s260_snd_v001.wav";
				#print audioFile
				flds['Shot'] = flds['Sequence']+"_"+seqShot
				audioOutputFile = audio_template.apply_fields(flds)
				#audioOutputPath = str.replace(str(audioOutputPath),"\\","/")
				#print audioFile
				audioFile = str.replace(str(audioFile),"Z:/Richard The Stork","W:/RTS")
				audioOutputPath = str.rsplit(str(audioOutputFile),"\\",1)[0]
				print audioOutputPath
				if os.path.exists(audioOutputPath):
					audioOutputFile = findLastVersion(audioOutputPath,True,True)
					if audioOutputFile != 0:
						newAudio = str.rsplit(audioOutputFile,"/",1)[-1]
						newAudio = str.split(newAudio,".")[0]
						print newAudio
						cmds.delete(audio)
						ref = cmds.file( audioOutputFile, r=True, type="audio",mergeNamespacesOnClash=False, namespace="audio")
						#
						offset = cmds.getAttr(seqShot+".sequenceStartFrame")
						cmds.setAttr(newAudio+".offset", offset)
						cmds.connectAttr(newAudio+".message", seqShot+".audio")
						
						shotEnd =  cmds.getAttr(seqShot +".sequenceEndFrame")
						audioEnd = cmds.getAttr(newAudio+".endFrame")
						if audioEnd < shotEnd:
							reportList += [newAudio + "  is shorter than shot !!!"]
						if audioEnd > shotEnd:
							reportList += [newAudio + "  was longer than shot. now cut to match!!!"]
							cmds.setAttr(newAudio+".endFrame",shotEnd+1)

						returnList += [newAudio]
				else:
					print "skipped ", audio
			for report in reportList:
				print report
			return returnList
Ejemplo n.º 4
0
        def setAudioToCorrectPath():
            scenePath = cmds.file(q=True, sceneName=True)
            scene_template = tk.template_from_path(scenePath)
            flds = scene_template.get_fields(scenePath)
            audio_template = tk.templates["shot_published_audio"]

            tank = sgtk.tank_from_entity('Project', 66)

            allShots = cmds.ls(type="shot")
            allAudio = cmds.ls(type="audio")
            reportList = []
            returnList = []
            for seqShot in allShots:
                audio = cmds.shot(seqShot, q=True, audio=True)
                audioFile = cmds.getAttr(
                    audio + ".filename"
                )  # "W:/RTS/1_PREPROD/13_ANIMATIC/q340/splitshots/wav new 01/q340_s260_snd_v001.wav";
                #print audioFile
                flds['Shot'] = flds['Sequence'] + "_" + seqShot
                audioOutputFile = audio_template.apply_fields(flds)
                #audioOutputPath = str.replace(str(audioOutputPath),"\\","/")
                #print audioFile
                audioFile = str.replace(str(audioFile), "Z:/Richard The Stork",
                                        "W:/RTS")
                audioOutputPath = str.rsplit(str(audioOutputFile), "\\", 1)[0]
                print audioOutputPath
                if os.path.exists(audioOutputPath):
                    audioOutputFile = findLastVersion(audioOutputPath, True,
                                                      True)
                    if audioOutputFile != 0:
                        newAudio = str.rsplit(audioOutputFile, "/", 1)[-1]
                        newAudio = str.split(newAudio, ".")[0]
                        print newAudio
                        cmds.delete(audio)
                        ref = cmds.file(audioOutputFile,
                                        r=True,
                                        type="audio",
                                        mergeNamespacesOnClash=False,
                                        namespace="audio")
                        #
                        offset = cmds.getAttr(seqShot + ".sequenceStartFrame")
                        cmds.setAttr(newAudio + ".offset", offset)
                        cmds.connectAttr(newAudio + ".message",
                                         seqShot + ".audio")

                        shotEnd = cmds.getAttr(seqShot + ".sequenceEndFrame")
                        audioEnd = cmds.getAttr(newAudio + ".endFrame")
                        if audioEnd < shotEnd:
                            reportList += [
                                newAudio + "  is shorter than shot !!!"
                            ]
                        if audioEnd > shotEnd:
                            reportList += [
                                newAudio +
                                "  was longer than shot. now cut to match!!!"
                            ]
                            cmds.setAttr(newAudio + ".endFrame", shotEnd + 1)

                        returnList += [newAudio]
                else:
                    print "skipped ", audio
            for report in reportList:
                print report
            return returnList