def generate_meta(gen, pattern): """Generate metadata from name and insert into the clip""" if not gen.status(True): return (False, "Generation not running.") if not os.path.isdir(epp_root): return (False, "Could not find EPP ROOT directory. Set the EPP_ROOT env variable first.", ) PAT_FILEBASENAME = re.compile(pattern) selected_versions = gen.selected_versions() if len(selected_versions) < 1: return (False, "No versions selected.") for version in selected_versions: meta = version.Metadata(gen.frame()) path = meta['Data']['File']['Path'] mat = PAT_FILEBASENAME.findall(path) if len(mat): shotname = mat[0] gen.add_meta(version, shotname) log.info("Setting metadata of {0} to {1}".format(version.Name, shotname)) else: log.warning("Skipping " + os.path.basename(path)) return (True, "")
def generate_meta(gen, pattern): """Generate metadata from name and insert into the clip""" if not gen.status(True): return (False, "Generation not running.") if not os.path.isdir(epp_root): return ( False, "Could not find EPP ROOT directory. Set the EPP_ROOT env variable first.", ) PAT_FILEBASENAME = re.compile(pattern) selected_versions = gen.selected_versions() if len(selected_versions) < 1: return (False, "No versions selected.") for version in selected_versions: meta = version.Metadata(gen.frame()) path = meta['Data']['File']['Path'] mat = PAT_FILEBASENAME.findall(path) if len(mat): shotname = mat[0] gen.add_meta(version, shotname) log.info("Setting metadata of {0} to {1}".format( version.Name, shotname)) else: log.warning("Skipping " + os.path.basename(path)) return (True, "")
def _setup(self): """ Setup the widgets """ epp_root = osplus.get_env("EPP_ROOT") if not os.path.isdir(epp_root): QMessageBox.critical( self, "Error", "Could not find EPP ROOT directory.\n{0}".format(epp_root)) return False self.settings = settings.XMLSettings( os.path.join(epp_root, "config.xml")) self.PROJECTROOT = self.settings.get("paths", "projectdir") if self.PROJECTROOT is None: QMessageBox.critical( self, "Error", "No Project Directory configured in config.xml.") return False self._setup_header(epp_root) self._setup_status() # Require Generation if not self._setup_generation(): msg = "Could not establish connection with Generation. Make sure it is running." log.error(msg, True) return False # Need edit rights for this one! if not self._gen.allow_changes(True): log.warning("Project locked.") return False if not self._setup_project(): msg = "Project directory from Generation Project invalid: {0}".format( self.PROJECTDIR) log.error(msg, True) return False if not self._setup_shot(): msg = "Project directory from Generation Project invald: {0}".format( self.PROJECTDIR) log.error(msg, True) return False return True
def _setup(self): """ Setup the widgets """ epp_root = osplus.get_env("EPP_ROOT") if not os.path.isdir(epp_root): QMessageBox.critical(self, "Error", "Could not find EPP ROOT directory.\n{0}".format(epp_root)) return False self.settings = settings.XMLSettings(os.path.join(epp_root, "config.xml") ) self.PROJECTROOT = self.settings.get("paths", "projectdir") if self.PROJECTROOT is None: QMessageBox.critical(self, "Error", "No Project Directory configured in config.xml.") return False self._setup_header(epp_root) self._setup_status() # Require Generation if not self._setup_generation(): msg = "Could not establish connection with Generation. Make sure it is running." log.error(msg, True) return False # Need edit rights for this one! if not self._gen.allow_changes(True): log.warning("Project locked.") return False if not self._setup_project(): msg = "Project directory from Generation Project invalid: {0}".format(self.PROJECTDIR) log.error(msg, True) return False if not self._setup_shot(): msg = "Project directory from Generation Project invald: {0}".format(self.PROJECTDIR) log.error(msg, True) return False return True
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
def _setup(self): """ Setup the widgets """ epp_root = osplus.get_env("EPP_ROOT") if not os.path.isdir(epp_root): log.error("Could not find EPP ROOT directory.\n{0}".format(epp_root), True) return False self.settings = settings.XMLSettings(os.path.join(epp_root, "config.xml") ) self.PROJECTROOT = self.settings.get("paths", "projectdir") if not self.PROJECTROOT.endswith(os.path.sep): self.PROJECTROOT = self.PROJECTROOT + os.path.sep if self.PROJECTROOT is None: log.error("No Project Directory configured in config.xml.", True) return False self._setup_header(epp_root) #self._setup_name_widget(epp_root) self._setup_status() # Require Generation if not self._setup_generation(): msg = "Could not establish connection with Generation. Make sure it is running." log.error(msg, True) return False # Need edit rights for this one! if not self._gen.allow_changes(True): return False if not self._setup_project(): msg = "Project directory from Generation Project invalid: {0}".format(self.PROJECTDIR) log.error(msg, True) return False if not self._setup_shot(): msg = "Project directory from Generation Project invald: {0}".format(self.PROJECTDIR) log.error(msg, True) return False selected_versions = self._gen.selected_versions() if len(selected_versions) < 1: msg = "No versions selected." log.error(msg, True) return False meta = selected_versions[0].Metadata(selected_versions[0].InPoint) self.preview_path = meta['Data']['File']['Path'] if not self._setup_patterns(epp_root): msg = "No parsing patterns found." log.warning(msg) return False # We can't work without structs if not self._setup_structs(epp_root): msg = "Could not find directory structure files in templates.\n{0}".format(os.path.join(epp_root, "templates", "shot_dirs")) log.error(msg, True) return False return True
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
def _setup(self): """ Setup the widgets """ epp_root = osplus.get_env("EPP_ROOT") if not os.path.isdir(epp_root): log.error( "Could not find EPP ROOT directory.\n{0}".format(epp_root), True) return False self.settings = settings.XMLSettings( os.path.join(epp_root, "config.xml")) self.PROJECTROOT = self.settings.get("paths", "projectdir") if not self.PROJECTROOT.endswith(os.path.sep): self.PROJECTROOT = self.PROJECTROOT + os.path.sep if self.PROJECTROOT is None: log.error("No Project Directory configured in config.xml.", True) return False self._setup_header(epp_root) #self._setup_name_widget(epp_root) self._setup_status() # Require Generation if not self._setup_generation(): msg = "Could not establish connection with Generation. Make sure it is running." log.error(msg, True) return False # Need edit rights for this one! if not self._gen.allow_changes(True): return False if not self._setup_project(): msg = "Project directory from Generation Project invalid: {0}".format( self.PROJECTDIR) log.error(msg, True) return False if not self._setup_shot(): msg = "Project directory from Generation Project invald: {0}".format( self.PROJECTDIR) log.error(msg, True) return False selected_versions = self._gen.selected_versions() if len(selected_versions) < 1: msg = "No versions selected." log.error(msg, True) return False meta = selected_versions[0].Metadata(selected_versions[0].InPoint) self.preview_path = meta['Data']['File']['Path'] if not self._setup_patterns(epp_root): msg = "No parsing patterns found." log.warning(msg) return False # We can't work without structs if not self._setup_structs(epp_root): msg = "Could not find directory structure files in templates.\n{0}".format( os.path.join(epp_root, "templates", "shot_dirs")) log.error(msg, True) return False return True