Here are my answers to your questions:
1. Is the <process> element not capable of executing a function and is
capable of calling the only the file (as processes)?
No, the <process> element cannot run a specific Python function (unless
you run a Python script with a main method that called that Python
function). The <process> element submits a START request to the STAF
PROCESS service which allows you to run most any process. This process
command can be any executable (e.g. "python test.py", "java Test", "perl
test.pl", "test.exe", etc). It is not specific to Python.
2. How is the best way to execute some functions from a jython code as a
process or a sub-job?
To run Python functions via a STAX job on the local STAX service machine,
you can run them as you normally would via Python after importing them.
For example:
<stax>
<defaultcall function="StartHere"></defaultcall>
<script>
import sys
sys.path.append("C:/Reg Test/jniwrap/jniwrap-2.9.5.jar")
sys.path.append("C:/Reg Test/jython/hwMods/SigGen")
sys.path.append("C:/Reg Test/jython/hwMods")
sys.path.append("C:/Reg
Test/jython/hwMods/carrierFreqAndLevelTest.py")
from carrierFreqAndLevelTest import *
</script>
<function name="StartHere">
<sequence>
<script>
pyOutput = FreqAndLevelTest()
</script>
<log message="1">pyOutput</log>
</sequence>
</function>
</stax>
You may want to use import and name qualification instead of "from" when
importing your Python module if you want to be able to reload the Python
module (to pick up any changes to the Python module without having to
unregister and re-register the STAX service. See question "4.1.6 Why
aren't changes to imported Python modules picked up in my STAX job?" in
the STAF/STAX FAQ at
http://staf.sourceforge.net/current/STAFFAQ.htm#d0e2027 for more
information. For example:
<stax>
<defaultcall function="StartHere"></defaultcall>
<script>
import sys
sys.path.append("C:/Reg Test/jniwrap/jniwrap-2.9.5.jar")
sys.path.append("C:/Reg Test/jython/hwMods/SigGen")
sys.path.append("C:/Reg Test/jython/hwMods")
sys.path.append("C:/Reg
Test/jython/hwMods/carrierFreqAndLevelTest.py")
import carrierFreqAndLevelTest
</script>
<function name="StartHere">
<sequence>
<script>
reload(carrierFreqAndLevelTest)
pyOutput = carrierFreqAndLevelTest.FreqAndLevelTest()
</script>
<log message="1">pyOutput</log>
</sequence>
</function>
</stax>
Note that if you wanted to run the Python functions on a remote machine,
then you would need to do it differently. Post again if you need an
example of how to run Python functions on a remote machine.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, [EMAIL PROTECTED]
(512) 286-7313 or Tieline 363-7313
[EMAIL PROTECTED]
12/01/2008 05:46 AM
To
staf-users@lists.sourceforge.net
cc
Subject
[staf-users] Unable to execute a process and getting the error: "The
process failed to start, RC: 10"
Hi,
Hello I'm trying to execute the following STAX job file and I'm getting
the following error:
The process failed to start, RC: 10, STAFResult: Error starting the
process. CreateProcess failed with OS RC 2: The system cannot find the
file specified. Invalid command: FreqAndLevelTest()
<stax>
<defaultcall function="StartHere"></defaultcall>
<script>
import sys
sys.path.append("C:/Reg Test/jniwrap/jniwrap-2.9.5.jar")
sys.path.append("C:/Reg Test/jython/hwMods/SigGen")
sys.path.append("C:/Reg Test/jython/hwMods")
sys.path.append("C:/Reg
Test/jython/hwMods/carrierFreqAndLevelTest.py")
from carrierFreqAndLevelTest import *
test = [ ['FirstTest', 'FreqAndLevelTest()'] ]
</script>
<function name="StartHere">
<sequence>
<process>
<location>'local'</location>
<command>test[0][1]</command>
<stdout>'C:/temp.out'</stdout>
<stderr mode="'stdout'"></stderr>
<returnstdout></returnstdout>
</process>
<if expr="RC != 0">
<log level="'error'">
'Process failed with RC=%s, Result=%s' % (RC, STAFResult)
</log>
<elseif expr="STAXResult != None">
<iterate var="fileInfo" in="STAXResult" indexvar="i">
<if expr="fileInfo[0] == 0">
<sequence>
<log level="'info'">fileInfo[0]</log>
</sequence>
<else>
<log level="'error'">
'Retrieval of file %s contents failed with RC=%s' % (i,
fileInfo[0])
</log>
</else>
</if>
</iterate>
</elseif>
<else>
<log level="'info'">'STAXResult is None'</log>
</else>
</if>
</sequence>
</function>
</stax>
carrierFreqAndLevelTest
CarrierFreqAndLevelTest is the jython file where in this file the function
FreqAndLevelTest() resides. Well the STAF is actually able to locate to
the Jython file but is not able to see the actual function in this file.
My question is :
1. Is the <process> element not capable of executing a function and is
capable of calling the only the file (as processes)?
2. How is the best way to execute some functions from a jython code as a
process or a sub-job?
Thanks and regards,
Rajat
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users