I need to run a batch render command via terminal, and use the mel callbacks, to run a python module.
The terminal command I'm using is this:
Render -preRender "python(\"import sys\nsys.path.append(\"/Volumes/raid/farm_script/\")\nfrom run_os import Farm\nFarm()\")" "/path/to/scene.mb";
Essentially, the command in the escaped string should be read like this:
import sys
sys.path.append("/Volumes/raid/farm_script/")
from run_os import Farm
Farm()
In Maya's script editor, running the above command in a python tab, does print out data.
Running the exact same script, in a mel tab but wrapped in a python function, also works fine!
In the 'Farm' class located under /Volumes/raid/farm_scripts/run_os.py
, I have this tiny little script.
class Farm():
def __init__(self):
self.run()
def run(self, *args):
print "=== TEST ===\n"
Which I'm seeing my print test in the script editor, however running this command, using the MEL callbacks in the batch render terminal, leaves me with an 'unexpected indentation error', after vigorous testing, I've found that it's coming from the from run_os import Farm
, so my question is, why does this line create the indentation error, there's no indentation at all as i'm using the \n
(newline) flag, unless I'm seriously mistaken!