Deadline Standalone Python Reference  9.0.12.0
Welcome

Introduction

This is the documentation for the Deadline Standalone Python API. The Standalone Python API can be used in Python for communicating with the HTTP API. In order to use the HTTP API you must have the Web Service running on a machine whose address and port number you know.

Set-up

In order to use the Standalone Python API you must have Python 2.7 or later installed. Copy the "Deadline" folder containing the Standalone Python API from //your/repository/api/python to the "site-packages" folder of your Python installation and the API is ready to use.

Using the API

First, a DeadlineCon object must be created, which is used to communicate with the Web Service to send and receive requests. First "import Deadline.DeadlineConnect as Connect", then create your connection object "connectionObject = Deadline.DeadlineConnect.DeadlineCon('WebServiceName', WebServicePortNumber)", where 'WebServiceName' is the DNS name or IP address of the machine currently running the Web Service and 'WebServicePortNumber' is the Web Service Port Number as configured in the [Repository Options] - [Web Service and Proxy Server] settings. By default it is: 8082. The "connectionObject" variable can now be used to communicate requests to the Web Service.

Example: Getting group names and suspending a job

import Deadline.DeadlineConnect as Connect
connectionObject = Connect.DeadlineCon('WebServiceName', 8082)
print connectionObject.Groups.GetGroupNames()
#["group1","group2","group3"]
jobId = ...(valid job ID)
print connectionObject.Jobs.SuspendJob(jobId)
#'Success'

All of the Standalone Python API functions return a Python dictionary, a Python list, or a Python string. Lists often contain dictionaries.

Example: Getting a list, a list containing dictionaries, a dictionary, and a string back.

import Deadline.DeadlineConnect as Connect
groupNames = connectionObject.Groups.GetGroupNames()
print groupNames[0]
#group1
jobs = connectionObject.Jobs.GetJobs()
print jobs[0]['FailedChunks']
#12
task = connectionObject.Tasks.GetJobTask(jobId, 0)
print task["Errs"]
#8
root = connectionObject.Repository.GetRootDirectory()
#'C:/DeadlineRepository'

Example: Getting a job, changing the pool and priority then saving it

import Deadline.DeadlineConnect as Connect
job = connectionObject.Jobs.GetJob(jobId)
print str(job['Props']['Pool'])
#none
job['Props']['Pool'] = unicode('jobPool')
print str(job['Props']['Pool'])
#jobPool
print str(job['Props']['Pri'])
#50
job['Props']['Pri'] = 75
print str(job['Props']['Pri'])
#75
connectionObject.Jobs.SaveJob(job)
#'Success'
job = connectionObject.Jobs.GetJob(jobId)
print str(job['Props']['Pool']) + ' ' +str(job['Props']['Pri'])

Example: Submitting a job using Python dictionaries

import Deadline.DeadlineConnect as Connect

if __name__ == '__main__':

    Deadline = Connect.DeadlineCon('WebServiceName', 8082)

    JobInfo = {
        "Name": "Submitted via Python",
        "UserName": "UserName",
        "Frames": "0-1",
        "Plugin": "VraySpawner"
        }

    PluginInfo = {
        "Version": "Max2014"
        }

    try:
        newJob = Deadline.Jobs.SubmitJob(JobInfo, PluginInfo)
        print newJob
    except:
        print "Sorry, Web Service is currently down!"