From: Daniel Browne <dbrowne@(email surpressed)>
Subject: Maya Python Submit
   Date: Tue, 12 Apr 2011 15:11:41 -0400
Msg# 2084
View Complete Thread (7 articles) | All Threads
Last Next
Hi Greg,

I'm revamping one of my submit tools and it appears that in order for me to feed parameters to the Maya submit window in your python version (or for that matter the Perl version) is by creating the "-last" settings file. Is that correct? I can't just feed in a dictionary?

-Dan


----------
Dan "Doc" Browne
System Administrator
Evil Eye Pictures

dbrowne@(email surpressed)
Office: (415) 777-0666 x105


   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Maya Python Submit
   Date: Tue, 12 Apr 2011 15:33:49 -0400
Msg# 2086
View Complete Thread (7 articles) | All Threads
Last Next
Daniel Browne wrote:
> I'm revamping one of my submit tools and it appears that in order for me to=
>  feed parameters to the Maya submit window in your python version (or for t=
> hat matter the Perl version) is by creating the "-last" settings file. Is t=
> hat correct? I can't just feed in a dictionary?

	Might need more info on what you're doing.

	Are you trying to invoke the python script as an external script?
	If so, the command line should accept -field arguments, eg:

os.system("python /path/to/submit-maya.py -field Frames 1-100 -field JobTitle TEST_123")

	Or if you're trying to manipulate the -last file so as to rewrite the
	file, then I'm not sure how a dict would work there; dicts are internal
	variables.. I might be missing something. The format of the -last file
	is a Key: Value file format that can be Loaded/Saved with the
	Rush.LoadInput() and Rush.SaveInput() functions in Rush.py

	By passing a dict, do you mean trying to 'import' the submit script
	and manipulate it directly by passing variables into the subroutines?
	If so, the script wasn't meant to be 'import'ed, but perhaps it could be
	modified to be. The only code provided for import is the Rush.py

-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

   From: Daniel Browne <dbrowne@(email surpressed)>
Subject: Re: Maya Python Submit
   Date: Tue, 12 Apr 2011 15:56:18 -0400
Msg# 2088
View Complete Thread (7 articles) | All Threads
Last Next
In essence this is what I was thinking of; internalizing the rush submit in Maya's python environment.

I wasn't ware of the -field parameter; I could try that instead.


On Apr 12, 2011, at 12:33 PM, Greg Ercolano wrote:

	By passing a dict, do you mean trying to 'import' the submit script
	and manipulate it directly by passing variables into the subroutines?
	If so, the script wasn't meant to be 'import'ed, but perhaps it could be
	modified to be. The only code provided for import is the Rush.py

----------
Dan "Doc" Browne
System Administrator
Evil Eye Pictures

dbrowne@(email surpressed)
Office: (415) 777-0666 x105


   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Maya Python Submit
   Date: Tue, 12 Apr 2011 16:38:43 -0400
Msg# 2089
View Complete Thread (7 articles) | All Threads
Last Next
Daniel Browne wrote:
> In essence this is what I was thinking of; internalizing the rush submit in=
>  Maya's python environment.
> 
> I wasn't ware of the -field parameter; I could try that instead.

    Yes, that's the intended use.

    However, I should make the submit scripts importable.
    I just got it to import by making two changes to the script:

1) Renaming the script from submit-maya.py to submit_maya.py.
   (The python import command doesn't like the dash in the name)

       [EDIT 04/12/11] -- Doing this involves changing this line
       at the top of the submit_maya.py script:
         
              BEFORE: Rush.SetProgName("submit-maya")
               AFTER: Rush.SetProgName("submit_maya")           # underbar!

2) Adding this above the '### MAIN' section, and indenting that section:

if __name__ == "__main__":

   so eg:

---- snip
###
### MAIN
###

if __name__ == "__main__":
    ret = 0
    i = 1
    while i < len(sys.argv):
        if   ( sys.argv[i] == "-submit"     ): MAIN_Submit()
        elif ( sys.argv[i] == "-render"     ): MAIN_Render()
        [..]
---- snip

    With those changes, I can import the script and bring up the GUI
    from the python interpreter, and submit a job, eg:

$ python
Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import submit_maya
>>> submit_maya.MAIN_Input()

    With this in mind, I'll try to redesign the script a little bit
    so that MAIN_Input() can accept an optional dict of presets.

    Hadn't really designed the script to be used this way, but I see
    where that could be quite handy.

    I've been working on the python submit-maya script, getting it up
    to date with the "Layers And Frames" stuff mentioned in this article
    for the perl version:
    http://seriss.com/cgi-bin/rush/newsgroup-threaded.cgi?-view+2059+2059+2060

    I should have a new python submit_maya script in a day or so
    that will have those features, as well as being 'importable'.
    I'll follow up in this thread with details.

-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Maya Python Submit
   Date: Tue, 12 Apr 2011 17:02:26 -0400
Msg# 2090
View Complete Thread (7 articles) | All Threads
Last Next
Greg Ercolano wrote:
> $ python
> Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import submit_maya
>>>> submit_maya.MAIN_Input()
> 
>     With this in mind, I'll try to redesign the script a little bit
>     so that MAIN_Input() can accept an optional dict of presets.

        OK Daniel, I've made a few small changes to the maya submit
        so that one can pass in a dict to preload the submit form, eg:

    $ python
    Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
    [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import submit_maya
    >>> submit_maya.MAIN_Input( {"Frames":"66-77"} )

	..so this would preload the Frames: field with "66-77".
	Turns out this was really easy to add.

	I can make this new script available to you if you like,
	though I'm still doing some testing ATM with the "Layers And Frames"
	I've been working on the last day or so, and am just doing final tests.

	I must admit, I'm really liking python over perl,
	no doubt about it.. a much better language for our purposes.

-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

   From: Daniel Browne <dbrowne@(email surpressed)>
Subject: Re: Maya Python Submit
   Date: Tue, 12 Apr 2011 17:09:07 -0400
Msg# 2091
View Complete Thread (7 articles) | All Threads
Last Next
That's cool Greg; sure, I'll give it a whirl. I couldn't see a way to do it myself since the submit script version I have seems dependent upon using the -last file to pass parameters to display the gui.

Python is great, though I dislike the lack of delimiter braces and the =~ regex operator from Perl.


On Apr 12, 2011, at 2:02 PM, Greg Ercolano wrote:

[posted to rush.general]

Greg Ercolano wrote:
> $ python
> Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import submit_maya
>>>> submit_maya.MAIN_Input()
> 
>    With this in mind, I'll try to redesign the script a little bit
>    so that MAIN_Input() can accept an optional dict of presets.

       OK Daniel, I've made a few small changes to the maya submit
       so that one can pass in a dict to preload the submit form, eg:

   $ python
   Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
   [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
>>> import submit_maya
>>> submit_maya.MAIN_Input( {"Frames":"66-77"} )

	..so this would preload the Frames: field with "66-77".
	Turns out this was really easy to add.

	I can make this new script available to you if you like,
	though I'm still doing some testing ATM with the "Layers And Frames"
	I've been working on the last day or so, and am just doing final tests.

	I must admit, I'm really liking python over perl,
	no doubt about it.. a much better language for our purposes.

-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

----------
Dan "Doc" Browne
System Administrator
Evil Eye Pictures

dbrowne@(email surpressed)
Office: (415) 777-0666 x105


   From: Greg Ercolano <erco@(email surpressed)>
Subject: Python digression..
   Date: Tue, 12 Apr 2011 17:33:12 -0400
Msg# 2092
View Complete Thread (7 articles) | All Threads
Last Next
Daniel Browne wrote:
> [posted to rush.general]
> 
> That's cool Greg; sure, I'll give it a whirl. I couldn't see a way to do it=
>  myself since the submit script version I have seems dependent upon using t=
> he -last file to pass parameters to display the gui.

	It actually merges well into the code that handles the -last file.
	It's the same function that handles the command line presets (eg. -fields).

> Python is great, though I dislike the lack of delimiter braces..

	Yes, I do miss the ability to control scoping of variables within
	procedures via braces.

	I would think python could do this with its indenting, but it doesn't
	work that way.

	There are hacky ways to do this, but I don't like them. For now we
	just live with the inability to control scoping until "python 3000" ;)

> and the regex operator from Perl.

	Actually the perl regex stuff is in python.
	Use "import re", eg:

	    try:
		(h,m,s) = re.search("(\d+):(\d+):(\d+)",hms).groups()
		# match worked
            except:
		# match failed..

	..where the perl equivalent might be:

		if ( hms =~ /(\d+):(\d+):(\d+)/ ) {
		    # match worked
		    my ($h,$m,$s) = ($1,$2,$3);
		} else {
		    # match failed
		}

        regex's are a good way to parse strings; I use em quite a lot
	throughout.

	You can also do search/replace using re.sub() and friends.

	See help(re), which self-describes as regexs 'similar to perl'.

	Seems like the one thing everyone can agree on are the additions
	perl brought to regex are a Good Thing. Perl regex has been imported
	to other languages, so it's almost always available somehow.

-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)