Exemplo n.º 1
0
    def _export(self, exportPath):

        id = self["publish"]["sandbox"]["id"]
        target_dir = nJoin(exportPath, id)
        assure_folder_exists(target_dir)

        target_rigging = nJoin(target_dir, '{}_rigging.ma'.format(id))
        target_shading = nJoin(target_dir, '{}_shading.ma'.format(id))
        target_animation = nJoin(target_dir, '{}_animation.ma'.format(id))
        target_test = nJoin(target_dir, '{}_test.ma'.format(id))
        target_data = nJoin(target_dir, '{}_data.json'.format(id))

        errors = []
        try:
            shutil.copy2(self["publish"]["sandbox"]["rigging"]["path"],
                         target_rigging)
        except:
            errors.append("failed to copy rigging file")

        try:
            shutil.copy2(self["publish"]["sandbox"]["shading"]["path"],
                         target_shading)
        except:
            errors.append("failed to copy shading file")

        try:
            shutil.copy2(self["publish"]["sandbox"]["animation"]["path"],
                         target_animation)
        except:
            errors.append("failed to copy animation file")
        # shutil.copy2(self["publish"]["sandbox"]["test"]["path"], target_test)

        exported_data = copy.deepcopy(self["publish"])
        exported_data["sandbox"]["base"] = target_dir
        exported_data["sandbox"]["rigging"]["path"] = target_rigging
        exported_data["sandbox"]["shading"]["path"] = target_shading
        exported_data["sandbox"]["animation"]["path"] = target_animation
        exported_data["sandbox"]["test"]["path"] = target_test

        self["publish"]["sandbox"]["base"] = target_dir
        self["publish"]["sandbox"]["rigging"]["path"] = target_rigging
        self["publish"]["sandbox"]["shading"]["path"] = target_shading
        self["publish"]["sandbox"]["animation"]["path"] = target_animation
        self["publish"]["sandbox"]["test"]["path"] = target_test

        with open(target_data, 'w') as DataFile:
            json.dump(exported_data, DataFile, indent=4)

        lprint("finished exporting data:")
        lprint(json.dumps(exported_data, indent=4))
        return errors
Exemplo n.º 2
0
    def _import(self, importPath):
        id = os.path.basename(importPath)
        data_file = nJoin(importPath, "{}_data.json".format(id))
        if not os.path.isfile(data_file):
            raise RuntimeError

        with open(data_file, "r") as DataFile:
            data = json.load(DataFile)

        projects = sb_projects.SB_LibProjects(None)
        time.sleep(0.1)

        project = projects.get_project(data["asset"][0])
        props = project.getAssetType(data["asset"][2])
        asset = props.getAsset(data["asset"][3])
        self.init_asset(asset)
        self["publish"] = copy.deepcopy(data)

        lprint("finished importing data")
Exemplo n.º 3
0
    def set_sandbox(self):
        # define the 'sandbox' for the publishing process

        id = uuid.uuid4()
        data = {}
        data["id"] = "{}".format(id)
        if self.root:
            asset_name = "_".join(self["publish"]["asset"][-2:])
            data["asset_name"] = asset_name
            root = os.path.join(self.root, asset_name)
        else:
            root = tempfile.gettempdir()

        assure_folder_exists(root)

        data["base"] = nJoin(root, "{}".format(id))

        data["rigging"] = {
            "path": nJoin(data["base"], '{}_rigging.ma'.format(id)),
            "path_mb": nJoin(data["base"], '{}_rigging.mb'.format(id)),
            "state": Publisher.waiting_to_start
        }

        data["shading"] = {
            "path": nJoin(data["base"], '{}_shading.ma'.format(id)),
            "state": Publisher.waiting_to_start
        }

        data["animation"] = {
            "path": nJoin(data["base"], '{}_animation.ma'.format(id)),
            "state": Publisher.waiting_to_start
        }

        data["test"] = {
            "path": nJoin(data["base"], '{}_test.ma'.format(id)),
            "state": Publisher.waiting_to_start
        }

        self["publish"]["sandbox"] = data
Exemplo n.º 4
0
    def process_publish(self, note=None):

        if note == "" or (not note):
            lprint('warning: must provide a note')
            raise PublishException("warning: must provide a note")

        # setup the copy paths
        public_path = self.public_task['version_repository']["dir"]["path"]
        next = self.public_task['version_repository']["dir"]["next"]
        dir = nJoin(public_path, next["suffix"])

        # this will not support xgen!!
        rigging_name = "{asset}_rigging_{version}.ma".format(
            asset=self.asset["name"], version=next["suffix"])
        rigging_name_mb = "{asset}_rigging_{version}.mb".format(
            asset=self.asset["name"], version=next["suffix"])
        shading_name = "{asset}_shading_{version}.ma".format(
            asset=self.asset["name"], version=next["suffix"])
        rigging = nJoin(dir, rigging_name)
        rigging_mb = nJoin(dir, rigging_name_mb)
        shading = nJoin(dir, shading_name)

        try:
            assure_folder_exists(dir)

            lprint("=== copying temp files: ===")
            lprint(self["publish"]["sandbox"]["shading"])
            lprint(self["publish"]["sandbox"]["rigging"])

            lprint("=== into public folders: ===")
            lprint(rigging)
            lprint(shading)

            lprint(self.public_task["master_rigging"]["dir"]["path"])
            lprint(self.public_task["master_shading"]["dir"]["path"])

            shutil.copy2(self["publish"]["sandbox"]["rigging"]["path"],
                         rigging)
            shutil.copy2(self["publish"]["sandbox"]["rigging"]["path_mb"],
                         rigging_mb)
            shutil.copy2(self["publish"]["sandbox"]["rigging"]["path"],
                         self.public_task["master_rigging"]["dir"]["path"])
            shutil.copy2(self["publish"]["sandbox"]["rigging"]["path_mb"],
                         self.public_task["master_rigging_mb"]["dir"]["path"])

            if self.require_shading:
                shutil.copy2(self["publish"]["sandbox"]["shading"]["path"],
                             shading)
                shutil.copy2(self["publish"]["sandbox"]["shading"]["path"],
                             self.public_task["master_shading"]["dir"]["path"])

            lprint("=== done copy ===")
        except:
            raise PublishException("warning: errors during files copying",
                                   traceback=traceback.format_exc())

        try:
            data_helper.insert_metadata_version_entry(
                path=self.public_task["dir"]["metadata_file"]["path"],
                version_number=[next["number"], str(0)],
                author=self["publish"]["public_stamp"]["Author"],
                note=note,
                key='versions',
                add_include=False,
                origin={
                    "rigging":
                    self["publish"]["public_stamp"]["Origin_rigging"],
                    "shading":
                    self["publish"]["public_stamp"]["Origin_shading"]
                })
        except:
            raise PublishException("warning: errors during metadata setup",
                                   traceback=traceback.format_exc())

        ##############################################################
        # Sync with Signiant
        ##############################################################
        with SyncContext(dependencies=DependencyType.RECURSIVE_PARTIAL,
                         description='Publishing of: {}'.format(
                             self.asset['name']),
                         priority=98) as sync:
            sync.append(self.public_task["master_rigging"]["dir"]["path"])
            sync.append(self.public_task["master_rigging_mb"]["dir"]["path"])
            sync.append(self.public_task["master_shading"]["dir"]["path"])
            sync.append(self.public_task["dir"]["metadata_file"]["path"])

        with SyncContext(dependencies=DependencyType.NONE,
                         description='Publishing of (aux data): {}'.format(
                             self.asset['name']),
                         priority=70) as sync:
            git_repo_path = os.path.join(self.rigging_task['dir']['path'],
                                         self.asset['name'])
            sync.append(git_repo_path)
            sync.append(rigging)
            sync.append(rigging_mb)
            sync.append(shading)
        ##############################################################

        try:
            self.public_task["parent"].add_note("Maya: {}".format(note))
        except:
            lprint("warning: failed to save note to ftrack - {}".format(
                traceback=traceback.format_exc()))
            # raise PublishException("warning: failed to save note to ftrack", traceback=traceback.format_exc())

        return {"public_path": public_path, "next": next}
Exemplo n.º 5
0
    def process_animation(self, load=True):
        ##############################################################################################################################
        # the animation should be processed in maya
        ##############################################################################################################################
        try:
            sl = self.get_selected_versions()
            saved_animation = ''
            saved_camera = None
            if load:
                dir = sl["anim_test"]["parent"]['dir']["path"]
                anim = os.path.basename(sl["anim_test"]["path"])
                saved_animation = nJoin(dir, "studiolibrary",
                                        "{}.anim".format(anim))
                saved_camera = nJoin(dir, "camera", "{}.anim.ma".format(anim))
                if not os.path.exists(saved_camera):
                    saved_camera = None

                self['publish']['animation_camera'] = saved_camera

            if not os.path.isdir(saved_animation) and load:
                lprint("no animation was found in {}".format(saved_animation))
                raise Exception(
                    "no animation was found in {}".format(saved_animation))

            from maya import cmds
            from pipeline.variants.pipeline_maya.utils import maya_helper
            reload(maya_helper)

            import studiolibrary
            from mutils import animation

            maya_helper.new_scene()
            ns = '{}_0001'.format(self.asset["name"])
            cmds.file(self["publish"]["sandbox"]["rigging"]["path"],
                      r=True,
                      f=True,
                      ns=ns,
                      esn=False)

            if load:
                apply_animation = animation.Animation.fromPath(saved_animation)
                apply_animation.load(namespaces=[ns])

                sFrame = apply_animation.startFrame()
                eFrame = apply_animation.endFrame()
                cmds.playbackOptions(ast=sFrame)
                cmds.playbackOptions(aet=eFrame)

                if saved_camera:
                    cmds.file(saved_camera, i=True, pr=True)

            else:
                cmds.playbackOptions(ast=0)
                cmds.playbackOptions(aet=1)

            assure_folder_exists(self["publish"]["sandbox"]["base"])
            maya_helper.save_scene_as(
                path=self["publish"]["sandbox"]["base"],
                file_name=os.path.basename(
                    self["publish"]["sandbox"]["animation"]["path"]))

            self.update_process_state(Publisher.ready, "animation")
            return True
            #TODO: close file...
        except:
            lprint(traceback.format_exc())
            return False