2016-05-24 34 views
2

我想發送瑪雅呈現給Deadline Software的農場。瑪雅截稿作業提交python命令

用於手動作業提交的Python命令Maya到最後期限。

import sys 
import subprocess 
import maya.cmds as cmds 

deadline = "C:\\Program Files\\Thinkbox\\Deadline\\bin\\deadlinecommand.exe" 
maya_exe = "C:\\Program Files\\Autodesk\\Maya2015\\bin\\render.exe" 

file_path = cmds.file(q=True, location=True) 

command = '%s ' \ 
      '-SubmitCommandLineJob ' \ 
      '-executable "%s" ' \ 
      '-name "File Name" ' \ 
      '"%s" ' % (deadline, maya_exe, file_path) 
process = subprocess.Popen(command, stdout=subprocess.PIPE) 
lines_iterator = iter(process.stdout.readline, b"") 
for line in lines_iterator: 
    print(line) 
    sys.stdout.flush() 

任何蟒蛇的方式來添加瑪雅呈現截止日期..?

+0

無關:1-您可以使用'r'C:\ Program ..''而不是'C:\\ Program ..' - 注意'r''前綴(它是一個原始的字符串文字)。 2-在括號內使用隱式行連續而不是反斜槓和命名格式變量以提高可讀性:'command =('{deadline}''...''..「{maya_exe}」'...'「{file_path} '').format(** vars())'3-你不需要重定向輸出,如果你所做的只是將它回顯到stdout:drop'stdout = PIPE'並且只使用'subprocess.check_call(command) '。 ||你的問題是什麼?如何在你的問題中重現命令,但沒有'deadlinecommand'程序? – jfs

+0

@ J.F.Sebastian感謝您分享真棒python提示。我正試圖啓動/提交瑪雅文件到截止日期由python渲染農場。 –

+1

您對當前腳本有什麼問題?你期望發生什麼?會發生什麼呢? (一步一步描述)。如果你有任何錯誤,將它們包含在你的問題中。提及你使用什麼軟件版本(OS,Python等)。問題並把信息放在那裏。我不知道*「通過python提交maya渲染農場截止日​​期」*,但是這個信息可以幫助其他人回答這個問題。 – jfs

回答

0

最後,我得到了發送瑪雅方式將作業呈現到截止日期渲染農場軟件。 我們需要做的就是寫2個工作文件的截止日期。 1. maya_deadline_job.job 2. maya_deadline_info.job

和deadlinecommand.exe 例如通過將這些文件作爲參數:

deadlinecommand.exe "maya_deadline_info.job" "maya_deadline_info.job" 

這裏是我的Python代碼

""" 
This script will submit current file to deadline for render 
""" 
import os 
import sys 
import subprocess 
import maya.cmds as cmds 


def maya_deadline_job(): 
    """ 
    this function will collect scene file information and write a job file 
    :return: 
    """ 
    renderer_name = 'File' 
    version = cmds.about(version=True) 
    project_path = cmds.workspace(q=True, directory=True) 
    width = cmds.getAttr("defaultResolution.width") 
    height = cmds.getAttr("defaultResolution.height") 
    output_file_path = cmds.workspace(expandName="images") 
    output_file_prefix = cmds.getAttr("defaultRenderGlobals.imageFilePrefix") 
    scene_file = cmds.file(q=True, location=True) 
    info_txt = 'Animation=1\n' \ 
       'Renderer={}\n' \ 
       'UsingRenderLayers=0\n' \ 
       'RenderLayer=\n' \ 
       'RenderHalfFrames=0\n' \ 
       'LocalRendering=0\n' \ 
       'StrictErrorChecking=1\n' \ 
       'MaxProcessors=0\n' \ 
       'AntiAliasing=low\n' \ 
       'Version={}\n' \ 
       'Build=64bit\n' \ 
       'ProjectPath={}\n' \ 
       'ImageWidth={}\n' \ 
       'ImageHeight={}\n' \ 
       'OutputFilePath={}\n' \ 
       'OutputFilePrefix={}\n' \ 
       'Camera=\n' \ 
       'Camera0=\n' \ 
       'Camera1=RENDERShape\n' \ 
       'Camera2=frontShape\n' \ 
       'Camera3=perspShape\n' \ 
       'Camera4=sideShape\n' \ 
       'Camera5=topShape\n' \ 
       'SceneFile={}\n' \ 
       'IgnoreError211=0'.format(renderer_name 
             version, 
             project_path, 
             width, 
             height, 
             output_file_path, 
             output_file_prefix, 
             scene_file) 

    maya_deadline_job_file = r'{}\maya_deadline_job.job'.format(os.getenv('TEMP')) 
    with open(maya_deadline_job_file, 'w') as job_file: 
     job_file.write(info_txt) 
    return maya_deadline_job_file 


def maya_deadline_info(): 
    """ 
    this function will collect maya deadline information and write a job file 
    :return: 
    """ 
    info_txt = 'Plugin=MayaBatch\n' \ 
       'Name=MY_FILE_NAME\n' \ 
       'Comment=Render Launch by Python\n' \ 
       'Pool=none\n' \ 
       'MachineLimit=0\n' \ 
       'Priority=50\n' \ 
       'OnJobComplete=Nothing\n' \ 
       'TaskTimeoutMinutes=0\n' \ 
       'MinRenderTimeMinutes=0\n' \ 
       'ConcurrentTasks=1\n' \ 
       'Department=\n' \ 
       'Group=none\n' \ 
       'LimitGroups=\n' \ 
       'JobDependencies=\n' \ 
       'InitialStatus=Suspended\n' \ 
       'OutputFilename0=C:/Users/raijv/Documents/maya/projects/default/images/masterLayer_2.iff.????\n' \ 
       'Frames=1-10\n' \ 
       'ChunkSize=1' 

    maya_deadline_info_file = r'{}\maya_deadline_info.job'.format(os.getenv('TEMP')) 
    with open(maya_deadline_info_file, 'w') as job_file: 
     job_file.write(info_txt) 
    return maya_deadline_info_file 


def submit_to_deadline(): 
    """ 
    this function will send current scene to deadline for rendering 
    :return: 
    """ 
    deadline_cmd = r"C:\Program Files\Thinkbox\Deadline\bin\deadlinecommand.exe" 
    job_file = maya_deadline_job() 
    info_file = maya_deadline_info() 
    command = '{deadline_cmd} "{job_file}" "{info_file}"'.format(**vars()) 
    process = subprocess.Popen(command, stdout=subprocess.PIPE) 
    lines_iterator = iter(process.stdout.readline, b"") 
    # Lets print the output log to see the Error/Success 
    for line in lines_iterator: 
     print(line) 
     sys.stdout.flush() 

submit_to_deadline() 

編輯info -

請勿在渲染器中使用cmds.getAttr(「defaultRenderGlobals.currentRenderer」 _name變量。使用將覆蓋渲染器的圖層。

1

我已經寫了一個出口商在瑪雅內部的nuke作業。它也應該和maya一起工作(即使我不理解你,你沒有使用最後期限腳本 - 請注意nuke的截止日期在.py中有一個提交者):

我用xml編輯了兩部分文件: nuke_submit_info.job nuke_plugin_info.job 查找瑪雅相同的文件,它應該做的伎倆

然後提交它們與「deadlinecommand」

def sumbit2deadline(): 
    FileName = "nuke_submit_info" 
    JobInfo = PathSaveFiles + FileName + ".job" 
    FileName = "nuke_plugin_info" 
    JobPlugIn = PathSaveFiles + FileName + ".job" 
    FileName = "NukeTemplate" 
    JobFile = PathSaveFiles + FileName + ".nk" 
    command = "deadlinecommand" + " " + JobInfo + " " + JobPlugIn + " " + JobFile 
    subprocess.Popen(command) 
+0

PathSaveFiles引用一個路徑,即:C:/ tmp / – DrWeeny