It's all about the answers!

Ask a question

CLA with python scripting


Leesen Padayachee (9960120) | asked Dec 06 '16, 6:43 a.m.
 Hi 

I am using the Command Line adapter with python scripts. I cannot seem to pass execution variable to this python script. There are examples that state that I need to define the a variable as "$qm_userName" ,

This does not seem to work in a python script. Please advise on how I need to define a variable in a python script so that I can pass execution variables from a Jazz test case level.

Thanks,
Leesen

2 answers



permanent link
David Mehaffy (90123238) | answered Dec 06 '16, 9:38 a.m.
JAZZ DEVELOPER
edited Dec 06 '16, 9:39 a.m.
These are passed to the script as environment variables

Something like this should work:

import os
name = os.environ("qm_userName")

etc

Comments
Leesen Padayachee commented Dec 07 '16, 1:49 a.m.

 Hi David


So you say this has to be done in the .py script itself? and not in the batch file that we execute from RQM? The article https://jazz.net/library/article/809 talks about a batch script and gives the example : if [ -z "$qm_userName" ]. 

Will this variable need to defined in the batch script also?

Thanks,
Leesen


permanent link
David Mehaffy (90123238) | answered Dec 07 '16, 10:03 a.m.
JAZZ DEVELOPER
Well you don't have to have a batch file.  If your python script is sophisticated enough you can directly invoke it instead of a wrapper script.  Anything you can type as a single command for the command prompt can be a CLA script.  I don't know about windows but Unix like operating systems would pass the environment from the invoking shell script to the python script as well.  Try it - it is very easy to test - have python print one of your passed variables.  If you do it as a CLA script the output will be captured in the stdout file that gets attached to the execution result.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.