Beispiel #1
0
    def meta_from_standins(self):
        """Recreate Metadata from Standins"""

        lock = self.app.UpdateLock()
        proj = self.app.ProjectGet()
        sub = proj.SubGet()
        track = sub.TrackGet()

        projectname = None
        shotname = None
        for i in range(int(track.ClipCount())):
            cur_clip = track.ClipGet(i)

            # First ClipV that has the metadata will be used
            for j in range(int(cur_clip.VersionCount())):
                cur_ver = cur_clip.VersionGet(j)
                loader = cur_ver.GetLoader()
                if loader is None:
                    continue

                filepath = loader.Filename

                if os.path.basename(filepath).lower() == "standin.png":
                    projectname, shotname = filesystem.project_shot_from_path(
                        filepath)
                    if shotname is not None:
                        cur_meta = cur_ver.Metadata(cur_ver.InPoint)
                        cur_meta['Data']['UserClip']['ShotName'] = shotname
                        cur_ver.Metadata(cur_ver.InPoint, cur_meta)
                        log.debug("Setting Metadata for {0}".format(shotname))

        self.app.UpdateUnlock(lock)
Beispiel #2
0
    def accept(self):
        """
        Check the connection.
        """
        projectname = self.PROJECTNAME
        shotname = self.cmbShot.currentText()
        shot_data = self.cmbShot.itemData(self.cmbShot.currentIndex())

        if not self._gen.status():
            log.error("Generation not running", True)
            return

        log.info("Importing Comps from {0} - {1}".format(
            projectname, shotname))

        if shot_data == "*":
            shots = filesystem.shots(self.PROJECTROOT, projectname)
        else:
            shots = {shotname: ""}

        for cur_shotname, cur_shotdir in shots.items():
            comps = filesystem.comps(projectname, cur_shotname)
            for comp in comps:
                log.debug("Inserting {0}".format(comp))
                comp = str(comp)
                self._gen.insert_media(cur_shotname, comp,
                                       self.chkShotLike.isChecked())

        super(UpdateShotDialog, self).accept()
Beispiel #3
0
    def meta_from_standins(self):
        """Recreate Metadata from Standins"""

        lock = self.app.UpdateLock()
        proj = self.app.ProjectGet()
        sub = proj.SubGet()
        track = sub.TrackGet()
        

        projectname = None
        shotname = None
        for i in range(int(track.ClipCount())):
            cur_clip =  track.ClipGet(i)

            # First ClipV that has the metadata will be used
            for j in range(int(cur_clip.VersionCount())):
                cur_ver = cur_clip.VersionGet(j)
                loader = cur_ver.GetLoader()
                if loader is None:
                    continue

                filepath = loader.Filename

                if os.path.basename(filepath).lower() == "standin.png":
                    projectname, shotname = filesystem.project_shot_from_path(filepath)
                    if shotname is not None:
                        cur_meta = cur_ver.Metadata(cur_ver.InPoint)
                        cur_meta['Data']['UserClip']['ShotName'] = shotname
                        cur_ver.Metadata(cur_ver.InPoint, cur_meta)
                        log.debug("Setting Metadata for {0}".format(shotname))

        self.app.UpdateUnlock(lock)
Beispiel #4
0
    def accept(self):
        """
        Check the connection.
        """
        projectname = self.PROJECTNAME
        shotname = self.cmbShot.currentText()
        shot_data = self.cmbShot.itemData(self.cmbShot.currentIndex())

        if not self._gen.status():
            log.error("Generation not running", True)
            return

        log.info("Importing Comps from {0} - {1}".format(projectname, shotname))

        if shot_data == "*":
            shots = filesystem.shots(self.PROJECTROOT, projectname)
        else:
            shots = {shotname:""}
        
        for cur_shotname, cur_shotdir in shots.items():
            comps = filesystem.comps(projectname, cur_shotname)
            for comp in comps:
                log.debug("Inserting {0}".format(comp))
                comp = str(comp)
                self._gen.insert_media(cur_shotname, comp, self.chkShotLike.isChecked())

        super(UpdateShotDialog, self).accept()
Beispiel #5
0
    def insert_media(self, shotname, filepath, only_matching=False):
        """docstring for insert_comp"""
        clipm = self.get_shot_clip(shotname)
        proj = self.app.ProjectGet()
        sub = proj.SubGet()
        track = sub.TrackGet()

        is_comp = os.path.splitext(filepath)[1].lower() == ".comp"

        if clipm is None:
            log.warning(
                "Shot {0} not found in Generation project.".format(shotname))
            return False

        mat = self.PAT_VER.match(os.path.basename(filepath))
        if mat is not None:
            target_base, target_ver, target_post = mat.groups()

        index = 0

        for j in range(int(clipm.VersionCount())):
            cur_ver = clipm.VersionGet(j)
            loader = cur_ver.GetLoader()
            cur_filepath = loader.Filename
            if loader is None:
                continue

            if is_comp:
                cur_filepath = loader.RefFilename()

            if cur_filepath is None:
                continue

            if cur_filepath.lower() == filepath.lower():
                log.debug("Media {0} already exists".format(
                    os.path.basename(filepath)))
                return False

            mat = self.PAT_VER.match(os.path.basename(cur_filepath))
            if mat is not None and target_ver is not None:
                base, ver, post = mat.groups()
                if int(ver) == int(target_ver) - 1:
                    index = cur_ver.Version

        if only_matching:
            if not os.path.basename(filepath).lower().startswith(
                    shotname.lower().replace(os.path.sep, "_")):
                log.debug("Skipping because not a shot media {0}".format(
                    os.path.basename(filepath)))
                return False

        #lock = self.app.UpdateLock()

        for i, loader in proj.DropFiles(str(filepath)).items():
            log.debug("Inserting {0} at {1}".format(os.path.basename(filepath),
                                                    index))
            # Latest one.
            last_ver = clipm.VersionGet(0)
            in_point = 0
            if last_ver is not None:
                in_point = last_ver.InPoint

            new_ver = clipm.VersionInsert(loader)
            #TODO: new_ver = clipm.VersionInsert(loader, index)
            new_ver.InPoint = in_point

        #self.app.UpdateUnlock(lock)

        return True
Beispiel #6
0
    def insert_media(self, shotname, filepath, only_matching=False):
        """docstring for insert_comp"""
        clipm = self.get_shot_clip(shotname)
        proj = self.app.ProjectGet()
        sub = proj.SubGet()
        track = sub.TrackGet()

        is_comp = os.path.splitext(filepath)[1].lower() == ".comp"

        if clipm is None:
            log.warning("Shot {0} not found in Generation project.".format(shotname))
            return False

        mat = self.PAT_VER.match(os.path.basename(filepath))
        if mat is not None:
            target_base, target_ver, target_post = mat.groups()

        index = 0

        for j in range(int(clipm.VersionCount())):
            cur_ver = clipm.VersionGet(j)
            loader = cur_ver.GetLoader()
            cur_filepath = loader.Filename
            if loader is None:
                continue

            if is_comp:
                cur_filepath = loader.RefFilename()

            if cur_filepath is None:
                continue

            if cur_filepath.lower() == filepath.lower():
                log.debug("Media {0} already exists".format(os.path.basename(filepath)))
                return False


            mat = self.PAT_VER.match(os.path.basename(cur_filepath))
            if mat is not None and target_ver is not None:
                base, ver, post = mat.groups()
                if int(ver) == int(target_ver)-1:
                    index = cur_ver.Version

        if only_matching:
            if not os.path.basename(filepath).lower().startswith(shotname.lower().replace(os.path.sep, "_")):
                log.debug("Skipping because not a shot media {0}".format(os.path.basename(filepath)))
                return False

        #lock = self.app.UpdateLock()

        for i, loader in proj.DropFiles(str(filepath)).items():
            log.debug("Inserting {0} at {1}".format(os.path.basename(filepath), index))
            # Latest one.
            last_ver = clipm.VersionGet(0)
            in_point = 0
            if last_ver is not None:
                in_point = last_ver.InPoint

            new_ver = clipm.VersionInsert(loader)
            #TODO: new_ver = clipm.VersionInsert(loader, index)
            new_ver.InPoint = in_point

        #self.app.UpdateUnlock(lock)
    
        return True
Beispiel #7
0
    apps["add_project"] = add_project.main
    apps["add_shot"] = add_shot.main
    apps["add_shot_from_media"] = add_shot_from_media.main
    apps["create_saver"] = create_saver.main
    apps["save_as"] = save_as.main
    apps["set_shot"] = set_shot.main
    apps["update_shot"] = update_shot.main
    apps["save_new_version"] = fu_con.save_new_version
    apps["meta_from_standins"] = gen_con.meta_from_standins

    parser = argparse.ArgumentParser(description='Process some integers.')
    parser.add_argument('module', metavar='module', type=str, nargs='+',
                       help='Which module to launch.')

    args = parser.parse_args()
    
    for module in args.module:
        if not module in apps:
            log.error("Module not found: " + module)
        else:
            log.info("Launching " + module)
            apps[module]()
    
if __name__ == '__main__':
    try:
        main()
    except Exception, e:
        log.exception(e)
    finally:
        log.debug("Exit")