Re: Passing arguments to Python script in batch

Date : Fri, 25 May 2007 12:14:06 -0400
To : XSI(at)Softimage.COM
From : "Bernard Lebel" <3dbernard(at)gmail.com>
Subject : Re: Passing arguments to Python script in batch
All right, thanks again for the help guys.

Bernard




On 5/25/07, Marc-André Belzile <mbelzile(at)softimage.com> wrote:


Yes. The bug was fixed for 6.0.

 ________________________________
 From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of
Halfdan Ingvarsson
Sent: May 25, 2007 11:10 AM
To: XSI(at)Softimage.COM
Subject: RE: Passing arguments to Python script in batch



I see. I tested this in 6.0, where it works. Might be a problem related to
5.11.

 - ½

 ________________________________
 From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of
Bernard Lebel
Sent: 25-May-2007 11:04
To: XSI(at)Softimage.COM
Subject: Re: Passing arguments to Python script in batch


That's exactly what I did in the first place.

# Code calling XSIBATCH

import sys
sys.path.append(
r'\\linuxserver\animation\xsi\workgroup_animation\data\scripts'
)
sys.path.append(
r'\\linuxserver\animation\db\ts\ts_workgroup\data\scripts'
)
import os

sScriptFile =
r'C:\Softimage\workgroups\ts_workgroup\data\scripts\ts_pipeline\ts_addpogeogroups.py'
sAbsModelFile = 'salut'

sCommand =
'C:/Softimage/XSI_5.11/Application/bin/XSIBatch.bat -script
%s -lang Python -main addPOGeoGroups -args - sabsmodelfile "%s"' %
(sScriptFile, sAbsModelFile)
os.system( sCommand )




# ts_addpogeogroups.py

def addPOGeoGroups( sabsmodelfile ):
    import win32com
    Application = win32com.client.Dispatch( 'XSI.Application' )
    xsi = Application.application
    xsi.logmessage( sabsmodelfile )






# Output:

COMMAND: -script
C:\Softimage\workgroups\ts_workgroup\data\scripts\ts_pipeline\ts_addpogeogroups.py
-lang Python -main addPOGeoGroups -args -sabsmodelfile "salu t"
#ERROR : Traceback (most recent call last):
#TypeError: addPOGeoGroups() takes exactly 1 argument (0 given)
# - [line 4294967295]
ERROR - Script failed.
FATAL - Script Aborted.

1




Bernard





On 5/25/07, Halfdan Ingvarsson <hingvars(at)softimage.com> wrote:
>
>
> Let's re-do this to avoid any confusion:
>
> Command line:
>     xsibatch -script myPythonScript.py -lang Python -main myPythonFunction
-args -bob  "my uncle"
>
> myPythonScript.py:
>
>     def myPythonFunction( bob ):
>         Application.LogMessage( "Who is Bob? Bob is " + bob )
>
> Output:
>     # INFO: Who is Bob? Bob is my uncle
>
>
>  - ½
>
>
> ________________________________
 From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of
Bernard Lebel
> Sent: 25-May-2007 10:29
>
> To: XSI(at)Softimage.COM
> Subject: Re: Passing arguments to Python script in batch
>
>
>
> So it's -args, -arg1, -<argument name>, <argument value>, -arg2,
-<argument name>, <argument value>?
> Same thing:
>
> COMMAND: -script
C:\Softimage\workgroups\ts_workgroup\data\scripts\ts_pipeline\ts_addpogeogroups.py
-lang Python -main addPOGeoGroups -args -arg1 -sAbsModelFile salut
> #ERROR : Traceback (most recent call last):
> #TypeError: addPOGeoGroups() takes exactly 1 argument (0 given)
> # - [line 4294967295]
> ERROR - Script failed.
> FATAL - Script Aborted.
>
>
>
> Unless I've misunderstood your post? If you meant with -sAbsModelFile that
it should be the actual argument value....
> -args -arg1 -<argument value> -arg2 -<argument value>
>
>
> COMMAND: -script
C:\Softimage\workgroups\ts_workgroup\data\scripts\ts_pipeline\ts_addpogeogroups.py
-lang Python -main addPOGeoGroups -args -arg1 -salut
> #ERROR : Traceback (most recent call last):
> #TypeError: addPOGeoGroups() takes exactly 1 argument (0 given)
> # - [line 4294967295]
> ERROR - Script failed.
> FATAL - Script Aborted.
>
>
>
> Using XSI 5.11 btw.
>
>
> Bernard
>
>
>
>
> On 5/25/07, Marc-André Belzile <mbelzile(at)softimage.com> wrote:
> > > COMMAND: -script
> > >
C:\Softimage\workgroups\ts_workgroup\data\scripts\ts_pipeline\ts_addpo
> > > geogroups.py -lang Python -main addPOGeoGroups -args -sAbsModelFile
> > > salut #ERROR : Traceback (most recent call last):
> > > #TypeError: addPOGeoGroups() takes exactly 1 argument (0 given) # -
> > > [line 4294967295] ERROR - Script failed.
> > > FATAL - Script Aborted.
> >
> > It seems you miss the -arg1 tag
> >
> > Try
> >
> > -script
C:\Softimage\workgroups\ts_workgroup\data\scripts\ts_pipeline\ts_addpogeogroups.py
-lang Python -main addPOGeoGroups -args -arg1 -sAbsModelFile
> >
> >
> >
> > -----Original Message-----
> > From: owner-xsi(at)Softimage.COM [mailto: owner-xsi(at)Softimage.COM] On
Behalf Of Francois Lord
> > Sent: May 25, 2007 9:45 AM
> > To: XSI(at)Softimage.COM
> > Subject: Re: Passing arguments to Python script in batch
> >
> > you're in 6.01, right?
> >
> > Bernard Lebel wrote:
> > > Still no luck, Marc-André.
> > >
> > >
> > > COMMAND: -script
> > >
C:\Softimage\workgroups\ts_workgroup\data\scripts\ts_pipeline\ts_addpo
> > > geogroups.py -lang Python -main addPOGeoGroups -args -sAbsModelFile
> > > salut #ERROR : Traceback (most recent call last):
> > > #TypeError: addPOGeoGroups() takes exactly 1 argument (0 given) # -
> > > [line 4294967295] ERROR - Script failed.
> > > FATAL - Script Aborted.
> > >
> > > 1
> > >
> > >
> > > And before someone asks, the function def looks like this:
> > >
> > > def addPOGeoGroups( arg1 ):
> > >
> > >
> > >
> > > Thanks
> > > Bernard
> > >
> > >
> > >
> > > On 5/24/07, *Marc-André Belzile* < mbelzile(at)softimage.com
> > > <mailto:mbelzile(at)softimage.com>> wrote:
> > >
> > >     The syntax is rather like :
> > >     -script foo.pys -main foo -args -arg1 1 -arg2 2
> > >
> > >
------------------------------------------------------------------------
> > >     *From:* owner-xsi(at)Softimage.COM <mailto: owner-xsi(at)Softimage.COM>
> > >     [mailto:owner-xsi(at)Softimage.COM <mailto:owner-xsi(at)Softimage.COM>]
> > >     *On Behalf Of *Bernard Lebel
> > >     *Sent:* May 24, 2007 3:59 PM
> > >     *To:* XSI(at)Softimage.COM <mailto: XSI(at)Softimage.COM>
> > >     *Subject:* Passing arguments to Python script in batch
> > >
> > >     Can you pass arguments to Python scripts when using -script in
> > >     XSIBATCH? I remember there used to be something about that, is it
> > >     fixed?
> > >
> > >     COMMAND: -script
> > >
C:\Softimage\workgroups\ts_workgroup\data\scripts\ts_pipeline\ts_addpogeogroups.py
> > >     -lang Python -main addPOGeoGroups -args ['salut']
> > >     //ERROR : Traceback (most recent call last):
> > >     //TypeError: addPOGeoGroups() takes exactly 1 argument (0 given)
> > >     // - [line 4294967295]
> > >     ERROR - Script failed.
> > >     FATAL - Script Aborted.
> > >
> > >
> > >     Thanks
> > >     Bernard
> > >
> > >
> >
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body:
> > unsubscribe xsi
> >
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body:
> > unsubscribe xsi
> >
>
>



--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.