0

I have a python script that is calling a bat script called testrunner.bat which in turns executes a TestSuite in SOAPUI. I actually have gotten the external call to work just fine with the following command:

Popen("testrunner.bat -s\"CCT000 - Deploy Software Release\" -R\"TestSuite Report\" -E\"Default environment\" -Ppath.packages.sq=Y:\\NIGHTLY C:\\CI\\HEDeployment\\CI-XXX-DeploySwRelease")

However, I need to be able to have the software "level" to be dynamic and need to pass the variable level into the command in place of "NIGHTLY" so I can specify if it's nightly software, or stable, etc. I have seen that I should break all the arguments up separately, but I am having a hard time.

1 Answer 1

2

subprocess.Popen() can take a list of arguments as well as a string. So, this should work for you:

release_type = "NIGHTLY"
Popen(['testrunner.bat', 
       '-s"CCT000 - Deploy Software Release"', 
       '-R"TestSuite Report"', 
       '-E"Default environment"', 
       '-Ppath.packages.sq=Y:' + release_type, 
       'C:CIHEDeploymentCI-XXX-DeploySwRelease'])

As mentioned in the docs, shlex.split can be very useful for splitting your original command string into pieces. However, at least in my case, I had to re-add the double quotes.

Also, recall that single-quoted strings can contain double quotes, and vice versa, so you don't need to escape the quotes here.

Sign up to request clarification or add additional context in comments.

1 Comment

I had to add a few backslashes for the path, but otherwise this is awesome. Thanks so much for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.