A question about a list and subprocess.check_call()
David Aldrich
David.Aldrich at EMEA.NEC.COM
Mon Feb 16 09:03:55 EST 2015
Hi
I wonder if someone could help me with this problem please. I am writing a Python script that builds and tests a C++ program on Linux. The build options depend on the test, so I have encapsulated the 'make' call in a Python function:
def build(build_options=''):
if len(build_options):
subprocess.check_call(['make',build_options])
else:
subprocess.check_call('make')
This works fine if I call:
build()
or
build('flagA=true')
The latter gives:
make flagA=true
which is correct.
However, I now want to call make with two flags:
make flagA=true flagB=true
I tried calling:
build('flagA=true flagB=true')
which did indeed result in:
make flagA=true flagB=true
but 'make' ignored the second option. So I think that the list that was passed to subprocess.check_call() was incorrect.
In summary, I want to pass a list to build(), which by default should be empty, and pass that list on to subprocess.check_call() with 'make' as the first element of the list.
Any ideas please?
Best regards
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150216/dbc8056c/attachment.html>
More information about the Python-list
mailing list