How is your Python code within a <script> element failing? What error are
you currently getting?
As Python doesn't know anything about a STAX <throwexception> element, you
couldn't have Python code within a <script> element directly throw a STAX
exception. But, I suppose you could use Python's try / except block
syntax within your <script> to catch whatever Python exception you are
getting and then set a Python variable to indicate an error occurred (e.g.
pythonException = ...) and then check this variable using an <if> element
and if it indicates an error occurred, then throw a STAX exception by
doing <throwexception="'eTerminateFunction'">msg</throw>. For more
information on handling Python exceptions, see
http://wiki.python.org/moin/HandlingExceptions (or you can google for more
information on handling Python exceptions).
For example, you could do something like:
<script>
pythonExceptionMsg = None # No Python exception
try:
# Your python code
except:
pythonExceptionMsg = 'A python exception occurred'
</script>
<if expr="pythonException != None">
<throw exception="'eTerminateFunction'">pythonExceptionMsg</throw>
</if>
Or, if the Python error is resulting in a STAXPythonEvaluationError signal
being raised, then you could override the STAX default signal handler
handler for a STAXPythonEvaluationError and have it raise a STAX
eTerminateFunction exception instead of its default action which is to
"send a message that includes the variable named STAXPythonEvalMsg to the
STAX Monitor, log a message in the STAX Job Log with level 'error', and
terminate the job". Then, any time a STAXPythonEvaluationError signal is
raised anywhere in your STAX job, a STAX eTerminateFunction exception
would be thrown. See example 2 in section "Hhow to Perform Cleanup Before
Job Termination" in the STAX User's Guide at
http://staf.sourceforge.net/current/STAX/staxug.html#Header_CleanupExamples
for an example of overriding the default signalhandler for a
STAXPythonEvaluationError to throw a STAX Exception like one called
eTerminateFunction.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
From: Richard Pitkin/Westford/IBM@Lotus
To: staf-users@lists.sourceforge.net
Date: 07/06/2011 04:38 PM
Subject: [staf-users] question about stax and python
I have a multi line <script>section that prepares some variable for a copy
of files. It is possible to have one of these steps fail.
Now if this was more using stax tags I would use a throw construct, such
as:
<throwexception="'eTerminateFunction'">msg</throw>
So my question is it possible within a <script>tag in the Python to throw
this kind of exception? This rather than breaking apart the script code
just to make a test in stax tags so that an exception can be thrown.
regards,
Richard Pitkin
Lotus Software, IBM Software Group
978-899-3157 t/l 276-3157
richard_pit...@us.ibm.com
"For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled." R. P. Feynman, "Report of the
Presidential Commission on the Space Shuttle Challenger Accident"
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users