def process(self, context): assert all(result["success"] for result in context.data["results"]), ( "Publishing not succesfull so version is not increased.") from openpype.lib import version_up path = context.data["currentFile"] nuke.scriptSaveAs(version_up(path)) self.log.info('Incrementing script version')
def process(self, instance): errored_plugins = get_errored_plugins_from_data(instance.context) if errored_plugins: raise RuntimeError( "Skipping incrementing current file because publishing failed." ) scene_path = version_up(instance.context.data["currentFile"]) aftereffects.stub().saveAs(scene_path, True) self.log.info("Incremented workfile to: {}".format(scene_path))
def process(self, context): assert all(result["success"] for result in context.data["results"]), ( "Publishing not succesfull so version is not increased.") from openpype.lib import version_up path = context.data["currentFile"] filepath = version_up(path) avalon.blender.workio.save_file(filepath, copy=False) self.log.info('Incrementing script version')
def process(self, instance): errored_plugins = get_errored_plugins_from_data(instance.context) if errored_plugins: raise RuntimeError( "Skipping incrementing current file because publishing failed." ) scene_dir = version_up( os.path.dirname(instance.context.data["currentFile"])) scene_path = os.path.join(scene_dir, os.path.basename(scene_dir) + ".xstage") harmony.save_scene_as(scene_path) self.log.info("Incremented workfile to: {}".format(scene_path))
def process(self, context): from openpype.lib import version_up from openpype.action import get_errored_plugins_from_data errored_plugins = get_errored_plugins_from_data(context) if any(plugin.__name__ == "FusionSubmitDeadline" for plugin in errored_plugins): raise RuntimeError("Skipping incrementing current file because " "submission to render farm failed.") comp = context.data.get("currentComp") assert comp, "Must have comp" current_filepath = context.data["currentFile"] new_filepath = version_up(current_filepath) comp.Save(new_filepath)
def process(self, context): import os from maya import cmds from openpype.lib import version_up from openpype.action import get_errored_plugins_from_data errored_plugins = get_errored_plugins_from_data(context) if any(plugin.__name__ == "MayaSubmitDeadline" for plugin in errored_plugins): raise RuntimeError("Skipping incrementing current file because " "submission to deadline failed.") current_filepath = context.data["currentFile"] new_filepath = version_up(current_filepath) # # Ensure the suffix is .ma because we're saving to `mayaAscii` type if new_filepath.endswith(".ma"): fileType = "mayaAscii" elif new_filepath.endswith(".mb"): fileType = "mayaBinary" cmds.file(rename=new_filepath) cmds.file(save=True, force=True, type=fileType)
def _format_filepath(session): project = session["AVALON_PROJECT"] asset = session["AVALON_ASSET"] # Save updated slap comp work_path = _get_work_folder(session) walk_to_dir = os.path.join(work_path, "scenes", "slapcomp") slapcomp_dir = os.path.abspath(walk_to_dir) # Ensure destination exists if not os.path.isdir(slapcomp_dir): log.warning("Folder did not exist, creating folder structure") os.makedirs(slapcomp_dir) # Compute output path new_filename = "{}_{}_slapcomp_v001.comp".format(project, asset) new_filepath = os.path.join(slapcomp_dir, new_filename) # Create new unqiue filepath if os.path.exists(new_filepath): new_filepath = pype.version_up(new_filepath) return new_filepath
def switch(asset_name, filepath=None, new=True): """Switch the current containers of the file to the other asset (shot) Args: filepath (str): file path of the comp file asset_name (str): name of the asset (shot) new (bool): Save updated comp under a different name Returns: comp path (str): new filepath of the updated comp """ # If filepath provided, ensure it is valid absolute path if filepath is not None: if not os.path.isabs(filepath): filepath = os.path.abspath(filepath) assert os.path.exists(filepath), "%s must exist " % filepath # Assert asset name exists # It is better to do this here then to wait till switch_shot does it asset = io.find_one({"type": "asset", "name": asset_name}) assert asset, "Could not find '%s' in the database" % asset_name # Get current project self._project = io.find_one({"type": "project", "name": api.Session["AVALON_PROJECT"]}) # Go to comp if not filepath: current_comp = avalon.fusion.get_current_comp() assert current_comp is not None, "Could not find current comp" else: fusion = _get_fusion_instance() current_comp = fusion.LoadComp(filepath, quiet=True) assert current_comp is not None, ( "Fusion could not load '{}'").format(filepath) host = api.registered_host() containers = list(host.ls()) assert containers, "Nothing to update" representations = [] for container in containers: try: representation = fusion_lib.switch_item( container, asset_name=asset_name) representations.append(representation) except Exception as e: current_comp.Print("Error in switching! %s\n" % e.message) message = "Switched %i Loaders of the %i\n" % (len(representations), len(containers)) current_comp.Print(message) # Build the session to switch to switch_to_session = api.Session.copy() switch_to_session["AVALON_ASSET"] = asset['name'] if new: comp_path = _format_filepath(switch_to_session) # Update savers output based on new session _update_savers(current_comp, switch_to_session) else: comp_path = pype.version_up(filepath) current_comp.Print(comp_path) current_comp.Print("\nUpdating frame range") update_frame_range(current_comp, representations) current_comp.Save(comp_path) return comp_path