On Mon, Dec 1, 2008 at 5:05 PM, Sharon Lucas <[EMAIL PROTECTED]> wrote:

>
> 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#d0e2027for 
> 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.
>
>
Dear Sharon,

Thanks for those details.
Yes, I can use <script> as you told element to call the Python function.
     <script>
          outPut = FreqAndLevelTest()
     </script>

However, it alone does not solves the purpose. Using <script> forbids me
from checking the status of the test (such as RC and STAXResult). So, in a
way it forbids me from using the various other excellent features of STAX
like testcase, process, block,  logging and monitoring.

I have this following test enviorment to test the C Dlls where I'm trying to
use the STAX. I'ld apprciate if you can suggest me some other way around:

My setup is like:

STAF/STAX <------------> Jython <------------> Java(JNI) <------------> C
DLL

Java together with JNI has wrapper functions for the APIs in C DLL.
Testcases perform certain computations and are written in Jython.(For
clarity I call them as *Tests*). These tests are basically the jython
modules with functions defined to do the required testing / computation.

Through STAX (stax job file, I call them as *Testcases*) I'm intending to
call the Tests in Jython. So far I'm able to call create Tests in Jython and
have been able to tests some functionality.

I'm not able to understand what is the best way to call these Tests(or the
functions in modules) in terms of xml elements i,e. <process>, <job>,
<testcases>

I'm under the impression that I would have <testcase> element for each one
of those tests (i,e the functions in jython modules) so that using the
<tcsstatus> I can have a  Pass / Fail verdict. Inside <testcase> element I
would call  the <process> that will actually call the Test (i.e.the
function) and I will have all its stdout/stderr written to the STAX Job User
Log as wells as to the file (where they actually write).

Please suggest how is the best way to implement this. Should I make changes
to Python Tests by implementing them straight in the <script> element.

Many thanks.

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

Reply via email to