C4DR13 submitter

Hi there,

I have issues getting the SubmitToDeadline script to work in C4D R13 and DL 5.2. The strangest things happen.
When I install the script via the Monitor it copies SubmitToDeadline.pyp to the C4D plugin directory. When launching C4D there’s no plugin menu item and when I go to “Script/User scripts/Run Script…” and choose the .pyp it errors “Unknown script file”.
I took a look at the file and as it seems to be standard python I changed the extension to .py for testing purposes. When I run it again the console shows this error:

[code]||----------------------------------------
|| Enhance:C4D v1.00.032
|| © 1997 - 2009 Richard Jennings
|| http://www.shaders.co.uk
|| © 2005 - 2009 Montesano Development LLC
|| http://www.biomekk.com
||----------------------------------------


VrayForC4D Win64 1.2.6 www.vrayforc4d.com


Appending “/submission/Cinema4D” to system path to import SubmitC4DToDeadline module
Traceback (most recent call last):
File “‘scriptmanager’”, line 27, in
File “‘scriptmanager’”, line 23, in main
ImportError: No module named SubmitC4DToDeadline[/code]

As I first thought it might not get the correct repository path I wrote the full path directly into the script. Printing sys.path showed the correct target path in the repository appended to the list (in our case “\dl\deadlinerepository\submission\Cinema4D”).
Still it can’t find the module SubmitC4DToDeadline which is the python script located at that path, isn’t it?
I also took a look at that file and there is one function I want to ask you about.
In line 14 it says:

class SubmitC4DToDeadlineDialog (gui.GeDialog):

Is that correct or should it be called GetDialog?
However, as the main function shall be called I wonder if the main function correctly only registers the submission script as a plugin. I am no programmer and only learn python by doing right now so I apologize if any of the questions are really dumb (:.
Not sure how others get it to work because with the default scripts nothing happens here. I am downloading the DL6 repository right now and will see if the scripts work.

Do you have any suggestions or ideas on how the problem can be solved?

In addition, when I try to use the old .cof instead, the menu item exists but initiating the plugin freezes C4D completely!?

As mentioned I printed the sys.path once and I could see that it looks really messy as if there are all kind of wrong paths appended, too, and only the last ones are correct. Is that normal or is there a way to clean up the sys.path (shouldn’t it reset for every script?)?

Please, help me! Any response is appreciated.

Kind regards,
Dziga

I just tried another approach.

I opened the Script Manager in C4D and executed the SubmitC4DToDeadline.py directly from the repository. Now, I atleast get the submission dialog but without a connection to our repository as neither pools nor groups are loaded.

So it seems the SubmitToDeadline.py (/.pyp) can’t find the repository correctly and therefore the SubmitC4DToDeadline.py isn’t imported at all. Checked it with print “IMPORT SUCCEEDED!” after import and it shows up.

Getting back to debugging…:slight_smile:

-Dziga

Edit:

After this part:

[code] else:
stdout = os.popen( “deadlinecommand GetRepositoryRoot” )

path = stdout.read()
path += "/submission/Cinema4D"
path = path.replace("\n","").replace( "\\", "/" )
print path[/code]

path only contains “/submission/Cinema4D” :confused:

Next test that failed:

I added
path += “Y:/submission/Cinema4D”
and mounted “\dl\deadlinerepository” as Y.
Results in a C4D crash (Application Error! popup). But no errors about importing the .py anymore! ^^

Sorry, that this becomes so chaotic again!

I think I tracked down the main issue: both python scripts don’t get the repository root. I don’t know why. When I manually open a command prompt and type deadlinecommand -GetRepositoryRoot it shows the correct path.
I used several print outs in the SubmitC4DToDeadline.py to analyze where C4D crashes. I moved the dialog creation out of the “if name==‘main’:” statement. Now the dialog opens and the console FINALLY prints the error that it couldn’t get the repository root. As a result I again don’t have pools and stuff and as soon as I close the dialog C4D crashes again. The last logged message is “Could not write sticky settings”.
Do you have an idea I how I could set the repository root to my mapped path directly in the script and see if it gets all neccessary values?

UPDATE*

I tried to debug the deadlinecommand. When I use this:

[code]import os

stdout = os.popen( “cd” )
path = stdout.read()
print "path " + path[/code]

I get “path C:\Program Files\MAXON\CINEMA 4D R13”

When I type this:

[code]import os

stdout = os.popen( “deadlinecommand” + “GetRepositoryRoot” )
path = stdout.read()
print "path " + path[/code]

I get "path ". So, in my case it doesn’t return the path when executed out of python.

We’ve seen cases where os.popen is unreliable in C4D. In Deadline 6, we’re actually in the process of converting it to use the subprocess module instead, and it seems to be working great. This will be part of the beta 7 release of D6, which we hope to get out next week.

For now, you could workaround the problem by hard coding the path to the repository in the .pyp file, rather then having it obtain it by running deadlinecommnad.exe.

Thanks for the info, Ryan. That was the only thing I didn’t try.I already hard coded in the python code I directly typed in C4D and the SubmitC4DToDeadline.py which didn’t work. Using the .pyp instead ALMOST works.
There is still an issue left. Now, I get the Plugin listed and I can initiate the dialog but the pools and groups are not received (no error though). And when I try to submit nothing happens.
Is there anything else I need to hard code because it tries to get the pools and groups via deadlinecommand, too? How would I replace these parts? What “path” does it expect for pools and groups?
And if the pools change, do I need to adjust the .py everytime? :confused: Looking through the .py I see quite a lot of deadlinecommand usage^^

update: After restarting C4D the plugin is gone again…

Aaaalso, how would I submit the job without using deadlinecommand? Can I install the new python library and use subprocess with DL5.2?

Kind regards,
Dziga

Puh, my head is exploding but I think I found a working implementation of subprocess (thought you need the newest python version first)

[code]from subprocess import Popen, PIPE, call
import subprocess

output = Popen([“C:/Program Files/Thinkbox/Deadline/bin/deadlinecommand.exe”, “-GetRepositoryRoot”], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,)

stdout_value, stderr_value = output.communicate()

print stdout_value[/code]

:astonished:

Can you help me with this part, please?

[code] # Submit the job to Deadline
args = “”" + jobInfoFile + “” “” + pluginInfoFile + “”"
print “arguments = " + args
if submitScene:
args += " “” + sceneFilename + “””

			results = ""
			try:
				output = Popen( ["C:\\Program Files\\Thinkbox\\Deadline\\bin\\deadlinecommand.exe", args], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, )
				stdout_value, stderr_value = output.communicate()
				results = stdout_value
				#stdout.close()

				print stdout_value
			except:
				results = "An error occurred while submitting the job to Deadline."
			
			c4d.StatusClear()
			
			gui.MessageDialog( results )[/code]

I get this error:
An Unexpected Error Occurred
Illegal characters in path. (System.ArgumentException)

It doesn’t print the arguments by the way.

Got it :slight_smile:
There was just a syntax issue for adding multiple arguments with subprocess.
This piece of code solves the issue for now:

[code] jobInfo = self.DeadlineHome + “\temp\c4d_submit_info.job”
pluginInfo = self.DeadlineHome + “\temp\c4d_plugin_info.job”
print "arguments = " + args
print “infoFiles = " + jobInfo + " " + pluginInfo
if submitScene:
args += " “” + sceneFilename + “””

			results = ""
			try:
				output = Popen( ["C:\\Program Files\\Thinkbox\\Deadline\\bin\\deadlinecommand.exe", jobInfo, pluginInfo], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, )
				stdout_value, stderr_value = output.communicate()
				results = stdout_value
				#stdout.close()

				print results[/code]

Kind regards,
Dziga