0

I am converting a command line to a python string. The command line is:

../src/clus -INFILE=../input/tua40.sq -OUTPUT=OUT

The python statement is:

c_dir = '~/prj/clus/'
c_bin = c_dir + 'src/clus'
c_data = c_dir + 'input/tua40.sq'

c = LiveProcess()
c.executable = c_bin
c.cwd = c_dir 
c.cmd = [c.executable] + ['-INFILE=', 'c_data, '-OUTPUT=OUT'] 

Problem is the c.cmd at the end looks like

~/prj/clus/src/clus -INFILE= ~/prj/clus/input/tua40.sq ...

Not that there is a 'space' after '=' which causes the program to report an error.

How can I concatenate '=' to the path?

4 Answers 4

6

LiveProcess is expecting an argv-style list of arguments. Where you want to make one argument, you need to provide one string. So use concatenation to make the string:

c.cmd = [c.executable] + ['-INFILE='+c_data, '-OUTPUT=OUT'] 

Also, no need for the list addition:

c.cmd = [c.executable, '-INFILE='+c_data, '-OUTPUT=OUT'] 
Sign up to request clarification or add additional context in comments.

Comments

0

Why don't you just concatenate string like this:

a = 'A'+'B'

then

a == 'AB'

that is in your example

['-INFILE=' + c_data, '-OUTPUT=OUT'] 

Comments

0

Given that it looks like you're concatenating paths, you should be using os.path.join, not regular string concat.

Comments

0

Try this:

c.cmd = [c.executable] + ['-INFILE='+c_data, '-OUTPUT=OUT']

1 Comment

You've over-concatenated there. "-OUTPUT" needs to start a new element.

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.