篇四 自己编写Houdini的Deadline任务提交节点

文章目录[x]
  1. 1:提交任务部分
  2. 2:交互响应部分

篇三 Houdini使用Deadline 提交任务节点

篇五 Deadline渲染农场十项使用奇技淫巧

 

提交任务部分

import hou

import os
import subprocess

#import traceback

#from CallDeadlineCommand import CallDeadlineCommand

 

#--------------------------超级用户 19870328

def ping():
import DeadlineConnect as Connect #DL 连接

connectionObject = Connect.DeadlineCon('192.168.11.254', 8082) # 连接对象
Gname = connectionObject.Groups.GetGroupNames() # 获取组信息
print(Gname)

def SubmitToDeadline():

#-----------------------------------------------------------------------------调用参数

nnode = str(hou.pwd().parm('newparameter52').eval())#渲染节点

dangqian = str(hou.applicationVersionString())#当前软件版本

renwu = str(hou.pwd().parm('newparameter45').eval() + '_' + nnode.split('/')[-1])#任务名

yonghu = str(hou.pwd().parm('newparameter54').eval())#用户名

beizhu = str(hou.pwd().parm('newparameter46').eval())#备注

bumen = str(hou.pwd().parm('newparameter49').eval())#部门

jiqi_i = int(hou.pwd().parm('newparameter47').eval())
dict_1 = {0:"houdini",1:"rs_2018",2:"nuke8"}
jiqi = str(dict_1.get(jiqi_i))#-------------------------------------机器池

zuyou_i = int(hou.pwd().parm('newparameter48').eval())
dict_2 = {0:"power",1:"lig",2:"farm"}
zuyou = str(dict_2.get(zuyou_i))#---------------------------------组优先级

renyou = str(hou.pwd().parm('newparameter50').eval())#任务优先级

lujing = str(hou.pwd().parm('newparameter51').eval())#路径

# zhenfanwei = int(hou.pwd().parm('newparameter').eval())#帧范围方式

# if zhenfanwei:
zhenlist = str(hou.pwd().parm('newparameter53').eval())#帧列表

# else:
# zhenlist = str(int(hou.frame()))#帧列表
# print(zhenlist)

meifen = str(hou.pwd().parm('newparameter59').eval())#每分发任务帧数

jiqiban_i = int(hou.pwd().parm('newparameter57').eval())
dict_3 = {0:"18.5",1:"18.0"}
jiqiban = str(dict_3.get(jiqiban_i))#-----------------------------机器版本

weishu = str(hou.pwd().parm('newparameter56').eval())#位数

#------------------------------------------------------------------------------------调用Api

# if __name__ == '__main__':
# print('1')

import sys

a = sys.path.append(r"\\192.168.11.254\DeadlineRepository10\api\python\Deadline")

import DeadlineConnect as Connect #DL 连接
# print(Connect.__file__)

connectionObject = Connect.DeadlineCon('192.168.11.254', 8082) # 连接对象
# print(connectionObject)

#--------------------------------------------------------------------------------------获取信息

# print(dir(connectionObject))

# Gname = connectionObject.Groups.GetGroupNames() # 获取组信息
# print(Gname)

# jjj = connectionObject.Jobs
# print(jjj)

# ggj = jjj.GetJobs
# print(help(ggj))

# ggjj = jjj.GetJob('5ff6c00da99aa83348268c04')
# print(ggjj)

# Jobs = Connect.Jobs.GetJobs()
# print(Jobs[0]['FaildChunks'])

#----------------------------------------------------配置信息

JobInfo = {

"Blacklist": "",
"ChunkSize": meifen,
"Comment": beizhu,
"EventOptIns": "",
"Frames": zhenlist,
"Group": zuyou,
# "MachineName": "xwpc143",
"Name": renwu,
"OverrideTaskExtraInfoNames": "False",
"Plugin": "Houdini",
# "Plugin": "VraySpawner",
"Pool": jiqi,
"Region": "",
# "ScheduledStartDateTime": "07/01/2021 16:02",
"UserName": yonghu
}

PluginInfo = {
"Build": weishu,
"IFD": "",
"IgnoreInputs": "False",
"Output": "",
"OutputDriver": nnode,
"SceneFile": lujing,
"Version": jiqiban
}

#---------------------------------------------------------------------提交任务

panduan = (renwu,yonghu,lujing,nnode,zhenlist,jiqi,zuyou)
nnew = [x for x in panduan if len(x)!=0]

if len(panduan) != len(nnew):
hou.ui.displayMessage('有必填项未填写 !')

else:

dayin = '提交信息确认(仅必填项) \n 任务名:' + renwu + '\n用户名:' + yonghu + '\n工程路径(公共地址):' + lujing + '\n 渲染节点:' + nnode + '\n 帧范围:' + zhenlist + '\n 机器池:' + jiqi + '\n 组的优先级:' + zuyou

uui = hou.ui.displayMessage(dayin,buttons=('确认','退出'))

if not uui:
try:
newJob = connectionObject.Jobs.SubmitJob(JobInfo,PluginInfo)
hou.ui.displayMessage('任务提交成功 !!!')
except:
print('服务当前是关闭的,或者提交参数不对')
else:
pass

#--------------------------------------------------------------手动拖入节点识别的方式 ( 已弃用 )
def tianru():

ssslnode = hou.selectedNodes()
if ssslnode:
slnode = ssslnode[0]
if slnode.type().name() == 'ifd':
slpath = str(slnode.path())
sllist = str(int(slnode.parm('f1').eval())) + '-' + str(int(slnode.parm('f2').eval()))
hou.pwd().parm('newparameter52').set(slpath)

zhenfanwei = int(hou.pwd().parm('newparameter').eval())#帧范围方式

if zhenfanwei:
hou.pwd().parm('newparameter53').set(sllist)#设置为帧列表

else:
hou.pwd().parm('newparameter53').set(str(int(hou.frame())))#设置为当前帧

# hou.pwd().parm('newparameter53').set(sllist)
else:
hou.ui.displayMessage('选择的节点不是mantra !')
else:
hou.ui.displayMessage('没有选择渲染节点 !')

#-----------------------------------------------------------------------------------打开序列所在路径
def dakai():

nnode = str(hou.pwd().parm('newparameter52').eval())#渲染节点
if nnode:
a = os.path.dirname(hou.node(nnode).parm('vm_picture').eval())

subprocess.Popen('explorer "{0}"'.format(a).replace("/", "\\"))
else:
hou.ui.displayMessage('尚未指定要查找的渲染节点')

#------------------------------------------------------------------------------------------其他 待测试

# # Get the repository path
# path = CallDeadlineCommand( [ "-GetRepositoryPath", "submission/Houdini/Main" ] ).strip()
# if path != "":
# path = path.replace( "\\", "/" )
#
# # Add the path to the system path
# if path not in sys.path :
# print "Appending \"" + path + "\" to system path to import SubmitDeadlineRop module"
# sys.path.append( path )
#
# # Import the script and call the main() function
# try:
# import SubmitDeadlineRop
# SubmitDeadlineRop.SubmitToDeadline()
# except:
# print( traceback.format_exc() )
# print( "The SubmitDeadlineRop.py script could not be found in the Deadline Repository. Please make sure that the Deadline Client has been installed on this machine, that the Deadline Client bin folder is set in the DEADLINE_PATH environment variable, and that the Deadline Client has been configured to point to a valid Repository." )
# else:
# print( "The SubmitDeadlineRop.py script could not be found in the Deadline Repository. Please make sure that the Deadline Client has been installed on this machine, that the Deadline Client bin folder is set in the DEADLINE_PATH environment variable, and that the Deadline Client has been configured to point to a valid Repository." )

 

 

 

交互响应部分

 

sn = kwargs["node"]
inp = sn.input(0)
if inp is None:
pass
else:
inp_r_s = str(int(inp.parm('f1').eval()))
inp_r_e = str(int(inp.parm('f2').eval()))
inp_r = inp_r_s + '-' + inp_r_e

inp_p = inp.path()

inp_r_f = int(inp.parm('trange').eval())
if inp_r_f:
sn.parm('newparameter').set(1)#当前帧
# sn.parm('newparameter53').set(sllist)#设置为帧列表
else:
sn.parm('newparameter').set(0)
# sn.parm('newparameter53').set(str(int(hou.frame())))#设置为当前帧

sn.parm('newparameter52').set(inp_p)
# sn.parm('newparameter53').set(inp_r)

sllist = str(int(inp.parm('f1').eval())) + '-' + str(int(inp.parm('f2').eval()))

zhenfanwei = int(sn.parm('newparameter').eval())#帧范围方式

if zhenfanwei:
sn.parm('newparameter53').set(sllist)#设置为帧列表

else:
sn.parm('newparameter53').set(str(int(hou.frame())))#设置为当前帧

 

点赞

发表回复

昵称和uid可以选填一个,填邮箱必填(留言回复后将会发邮件给你)
tips:输入uid可以快速获得你的昵称和头像