deadline api nuke

```Python
# nuke_ui.py
def _submit_deadline():
    sys.path.append(r'I:\script\bin\td\deadline\submit\python_api')
    
    import submit
    from submit import GetInfoTxtNuke, submit_to_deadline

    pool = _get_pool_str()

    p = nuke.Panel('Submit to Deadline')
    # p.addClipnameSearch('clip path', '/tmp')
    # p.addFilenameSearch('file path', '/tmp')
    # p.addTextFontPulldown('font browser', '/myFonts/')
    # p.addRGBColorChip('some pretty color', '')
    # p.addExpressionInput('enter an expression', '4*25')
    # p.addBooleanCheckBox('yes or no?', True)
    p.addEnumerationPulldown('pool', pool)
    # p.addScriptCommand('tcl or python code', '')
    p.addSingleLineInput('FrameRange', si['tStart'].value()+'-'+si['tEnd'].value())
    # p.addMultilineTextInput('multiple lines of user input text', 'lineA\nlineB')
    # p.addNotepad('write something', 'some very long text could go in here. For now this is just some random default value')
    # p.addPasswordInput('password', 'donttellanyone')
    # p.addButton('push here')
    # p.addButton('or here')
    # p.addButton('or even here')
    p.addSingleLineInput('ChunkSize', "1")
    p.addSingleLineInput('ExcuteNodes', "REN_EXR")
    p.addSingleLineInput('priority', "50")
    p.addSingleLineInput('machineLimit', "40")
    ret = p.show()
    
    if not ret: return

    # iKeyFrame = si['tKeyFrames'].value()
    # frames = iKeyFrame.replace(",", "-")
    # root_name = nuke.Root().name()
    # excuteNodes = "REN_EXR"

    frames = p.value('FrameRange')
    root_name = nuke.Root().name()
    chunkSize = p.value('ChunkSize')
    excuteNodes = p.value('ExcuteNodes')
    pool = p.value('pool')
    priority = p.value('priority')
    machineLimit = p.value('machineLimit')

    job_info_txt, plugin_info_txt = GetInfoTxtNuke(root_name, frames, chunkSize, excuteNodes, pool, priority, machineLimit)
    nuke.message(job_info_txt+""+plugin_info_txt)
    submit_to_deadline(job_info_txt, plugin_info_txt)
```

```Python
# submit.py
import os
import sys
import subprocess
import json

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


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


def submit_to_deadline(job_info_txt, plugin_info_txt):
    # Change deadline exe root
    deadline_cmd = r"C:\Program Files\Thinkbox\Deadline10\bin\deadlinecommand.exe"
    job_file = job_info(job_info_txt)
    info_file = plugin_info(plugin_info_txt)
    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()

def GetInfoTxtNuke(filePath, frames, chunkSize=1, excuteNodes="REN_EXR", pool="nuke", priority=50, machineLimit=30):
    job_info_txt = f"""
    Frames={frames}
    MachineLimit={machineLimit}
    ChunkSize={chunkSize}
    Group=nuke_13
    Name={os.path.basename(filePath)}
    OverrideTaskExtraInfoNames=False
    Plugin=CommandLine
    Pool={pool}
    Priority={priority}
    ScheduledStartDateTime=15/09/2022 16:08
    SecondaryPool=all
    UserName={os.getlogin()}
    MachineName=OA-MIS-18888
    """

    plugin_info_txt = f"""
    Arguments= -t -x -X {excuteNodes} -- {filePath} <STARTFRAME>,<ENDFRAME>,1
    Executable=I:/script/bin/td/bin/vd2_nuke13.0v2.bat
    Shell=default
    ShellExecute=False
    SingleFramesOnly=False
    StartupDirectory=
    """

    return str(job_info_txt.strip()), str(plugin_info_txt)
```

https://github.com/aizwellenstan/deadline_api_nuke