I can run (for the command line)
myscript.py '--pm execute.shell(cmd="ls -l", nonInteractive=True)'
But, suppose I was to debug myscript.py with and set the "Script parameters:" field in the Edit Configurations Python dialog to:
--pm execute.shell(cmd="ls -l", nonInteractive=True)
it barfs at space between "ls" and "-l". Is there a way to workaround this? Using ' or " quotes seems not to do it:
--pm 'execute.shell(cmd="ls -l", nonInteractive=True)'
--pm "execute.shell(cmd='ls -l', nonInteractive=True)"
In both cases, the quotes end up in the arguments.
Update: Running:
import sys
for x in sys.argv:
print "<%s>"%(x,)
with
Script parameters: a \ b " c" "\ d" ' e' '\ f' "a 'b' \"c\""
gives:
<cmd.py>
<a>
<\>
<b>
< c>
<\ d>
<'>
<e'>
<'\>
<f'>
<a 'b' "c">
So it looks like:
So, the magic answer is:
Script parameters: --pm "execute.shell(cmd='ls -l', nonInteractive=True)"
or
Script parameters: --pm "execute.shell(cmd=\"ls -l\", nonInteractive=True)"
I am not 100% sure about the issue. Since I don't have commenting privileges, I am writing it as answer.
Changing "ls -l" to "ls-\ l" should work, at least on *nix systems.
The relevant documentation/bug report is at https://youtrack.jetbrains.com/issue/PY-4715 and https://youtrack.jetbrains.com/issue/IDEA-72632 which states that you need to escape spaces using system dependent methods, and not using a generic method. The proposal for a generic system independent method was apparently denied.
EDIT: --pm" "execute.shell(cmd=\"ls" "-l\"," "nonInteractive=True) worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With