Q: How to register 'Arnold' render I followed the http://www.toadstorm.com/blog/?p=136 to open a maya scene without the UI.
This is the main script:
import maya.cmds as cmds
import subprocess
# replace mayaPath with the path on your system to mayapy.exe
mayaPath = 'C:/Program Files/Autodesk/Maya2018/bin/mayapy.exe'
# replace scriptPath with the path to the script you just saved
scriptPath = 'C:/Users/Rik/Desktop/CreateNewLayerWithMeshesForBatchRenderPurpose.py'
def massAddRenderLayer(filenames, layername):
    for filename in filenames:
        maya = subprocess.Popen(mayaPath+' '+scriptPath+' '+filename+' '+layername,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        out,err = maya.communicate()
        exitcode = maya.returncode
        if str(exitcode) != '0':
            print(err)
            print 'error opening file: %s' % (filename)
        else:
            print 'added new layer %s to %s' % (out,filename)


filenames = ['C:\Users\Rik\Desktop\Test_maya_file_FILE1.ma'] 
renderLayerToAdd = 'newRenderLayer'

massAddRenderLayer(filenames, renderLayerToAdd)

and this is the script that is called for:
import sys
import maya.standalone as std
std.initialize(name='python')
import maya.cmds as cmds
from mtoa.cmds.arnoldRender import arnoldRender
filename = sys.argv[1]
layername = sys.argv[2]

def addRenderLayer(filename,layername):
    try:
        cmds.file(filename,o=True,f=True)
        newLyr = cmds.createRenderLayer(n=layername,empty=True,makeCurrent=True)
        meshes = cmds.ls(type='mesh')
        xforms = []
        for i in meshes:
            xf = cmds.listRelatives(i,p=True)[0]
            xforms.append(xf)
            cmds.editRenderLayerMembers(layername,xforms)

        cmds.loadPlugin( 'mtoa.mll' )
        arnoldRender(1, 1, True, True,'camera1', ' -layer' + newLyr)
        cmds.setAttr("defaultArnoldDriver.ai_translator", "png", type="string")
        cmds.setAttr("defaultArnoldDriver.pre", "file_name", type="string")
        arnoldRender(1920, 1080, True, True,'camera1', ' -layer' + newLyr)

        sys.stdout.write(newLyr)
        return newLyr
    except Exception, e:
        sys.stderr.write(str(e))
        sys.exit(-1)

addRenderLayer(filename,layername)

When I run the main script he opens the mayapy.exe program, but when I want to render a frame then I get an error saying Failed to register renderer 'arnold' even when I have imported arnold and loaded the 'mtoa.mll' plugin.
How can I 'register 'arnold''?
