def init(node): nodePath = node.path() function = inspect.stack()[0][3] try: hou.hscript('setenv ASSET = '+path.asset(node)) hou.hscript('setenv COMPONENT = '+path.component(node)) hou.hscript('setenv JOB = '+path.hq_project_path(node).replace('\\','/')) #hou.putenv("ASSET", path.asset(node)) #hou.putenv("COMPONENT", path.component(node)) #hou.putenv("JOB", path.hq_project_path(node)) except (KeyboardInterrupt, SystemExit): log.node(node, 1, "Interrupt requested of "+function+" for "+nodePath+"...exiting") return
def delete(node): nodePath = node.path() function = inspect.stack()[0][3] try: #https://docs.python.org/2/library/os.html -os.walk history_root = path.hq_project_path(node) history_list = node.evalParm("history_list") history_cur = current(node) log.node(node, 1, "Deleting unlocked history") history_saved = [] if os.path.isdir(history_root): history_saved.append(history_root) if os.path.isdir(history_cur): history_saved.append(history_cur) subpath = os.path.normpath(os.path.dirname(history_cur)) if os.path.isdir(subpath): history_saved.append(subpath) for i in range(1, history_list + 1): hL = node.evalParm('history_lock' + str(i)) history_dir = os.path.normpath( node.evalParm('history_dir' + str(i))) if node.evalParm('history_dir' + str(i)) != '': if os.path.isdir(history_dir): history_saved.append(history_dir) if os.path.isdir(os.path.dirname(history_dir)): history_saved.append(os.path.dirname(history_dir)) log.node(node, 2, "Saved History: ") log.node(node, 2, str(history_saved)) for dirpath, dirnames, filenames in os.walk(history_root, topdown=True, onerror=None): if os.path.normpath(dirpath) not in history_saved: try: shutil.rmtree(dirpath) log.node(node, 1, "Deleting: " + os.path.normpath(dirpath)) except: log.node(node, 1, "Skipping: " + os.path.normpath(dirpath)) else: log.node(node, 1, " Saved: " + os.path.normpath(dirpath)) log.node(node, 1, "Finished deleting unlocked history") except (KeyboardInterrupt, SystemExit): print("Interrupt requested of " + function + " for " + nodePath + "...exiting") return
def execute(node): dC = node.evalParm('enable_ondelete') if dC == 1: path_cache = path.hq_project_path(node) if os.path.isdir(path_cache): log.node( node, 0, "The cache directory proposed to be removed is: " + path_cache) if not hou.hscriptExpression('opisquitting()'): if hou.ui.displayMessage( "Do you want to PERMANENTLY delete the caches created by: " + node.path(), buttons= ("Yes, I do not need these caches for any scene file or asset.", "No, I'll clean my files up later."), severity=hou.severityType.ImportantMessage, default_choice=1, close_choice=1, help= "Inorder to help with project cleanup, this is a method for you to help delete dead file trees on disk, and as the author of this content you'll know best if you'll ever need these files again. " + path_cache, title="File Cache Cleanup") == 0: if hou.ui.displayMessage( "As a warning these files can not be undeleted.", buttons= ("Yes, I understand I am deleting my caches forever.", "Oops, I do not want my caches deleted."), severity=hou.severityType.Warning, default_choice=1, close_choice=1, help= "As one last heads up we want to double check that you do want to delete your file caches PERMANENTLY. This is a check encase you've created any asset or are referencing these files in another scene. " + path_cache, title="File Cache Cleanup") == 0: log.node(node, 0, path_cache) shutil.rmtree(path_cache)
def execute_farm(node, localnode=None): if not localnode: localnode = node nodePath = node.path() function = inspect.stack()[0][3] try: begTime = datetime.datetime.now() log.node(node, 2, "\n Begin Time of Total Export: " + str(begTime) + " \n") if hq.hq_hfs(node)[1]: if node.parent().parm("file_type"): ext = node.parent().evalParm("file_type") if ext == 'md' or ext == 'ip': log.node( node, 0, "Not rendering to farm as your image type is set to Mplay." ) return renderscripts.pre(node) log.node(node, 2, "Rendering Node : " + str(node.path())) init(node) list_dir = [] list_dir.append(path.hq_project_path(node)) if node.parm("hq_hip_action"): if node.evalParm("hq_hip_action") == "use_target_hip": list_dir.append(os.path.dirname(path.hq_hip(node))) elif node.evalParm("hq_hip_action") == "use_ifd": list_dir.append(os.path.dirname(path.hq_input_ifd(node))) if node.parm("hq_makeifds"): if node.evalParm("hq_makeifds"): list_dir.append(os.path.dirname(path.hq_outputifd(node))) if localnode: ntype = localnode.type() name = ntype.nameComponents()[2] if name == 'VFX_geometry': list_dir.append(os.path.dirname(path.sopoutput(node))) if name == 'VFX_dop': list_dir.append(os.path.dirname(path.dopoutput(node))) if name == 'VFX_comp': list_dir.append( os.path.dirname(path.copoutput(node, localnode))) if name == 'VFX_opengl': list_dir.append( os.path.dirname(path.picture(node, localnode))) if name == 'VFX_ifd': list_dir.append( os.path.dirname(path.vm_picture(node, localnode))) if localnode.parm("soho_outputmode"): if localnode.evalParm("soho_outputmode"): list_dir.append( os.path.dirname(path.soho_diskfile(node))) if localnode.parm("vm_inlinestorage"): if not localnode.evalParm("vm_inlinestorage"): list_dir.append( os.path.dirname( path.vm_tmpsharedstorage(node))) list_dir.append( os.path.dirname(path.vm_tmplocalstorage(node))) if localnode.parm("vm_deepresolver"): if localnode.evalParm("vm_deepresolver") == 'shadow': list_dir.append( os.path.dirname(path.vm_dsmfilename(node))) if localnode.evalParm("vm_deepresolver") == 'camera': list_dir.append( os.path.dirname(path.vm_dcmfilename(node))) #relying on soho_mkpath for Extra Image Planes to make the directories #vm_filename_plane(hq_node,node,parm) makedirs(node, list_dir) save(node, 'farm') #Print the environment at the time of processing env_path = str( path.hq_project_path(node) + '/houdini_environment.json') log.node(node, 2, "Houdini Environemt Log : \n" + env_path) log.env(node, env_path) if oppath.node_sim(node): log.node(node, 2, "Submitting Simulation") node.node("hq_sim/hq_sim").parm('execute').pressButton() else: log.node(node, 2, "Submitting Renders") node.node("hq_render").parm('execute').pressButton() renderscripts.post(node) else: hou.ui.displayMessage( "Not deployed to the farm due to version mismatch.", title="Version Mismatch") log.node(node, 2, "Done with all Processing! \n") #TimeCheck endTime = datetime.datetime.now() tolTime = endTime - begTime log.node(node, 2, "End Time of Total Export: " + str(endTime)) log.node(node, 2, "Total Time of Export: " + str(tolTime) + " \n") except (KeyboardInterrupt, SystemExit): log.node( node, 1, "Interrupt requested of " + function + " for " + nodePath + "...exiting") return