Subprocess () in Python

I have an argument in Python that calls my subprocess (). Argument:

--server-args="-screen 0, 1280x800x24" args = [ 'xvfb-run', '--server-args="-screen 0, 1280x800x24"', '/usr/bin/python', '/root/AdamN-python-webkit2png-3ae4322/webkit2png.py', '-o', filename, url, ] 

I think he escapes double quotes. Is there any work for this?

+4
source share
2 answers

As long as you probably understood this in the last two years, I had the same problem today. Decision:

 import subprocess subprocess.check_call(['xvfb-run', '-s', '-screen 0 1024x768x24', 'CutyCapt', '--url=http://www.google.com/', '--out=google.png']) 

or

 import subprocess subprocess.check_call(['xvfb-run', '--server-args=-screen 0 1024x768x24', 'CutyCapt', '--url=http://www.google.com/', '--out=google4.png']) 

Suppose you have xvfb installed. I use CutyCapt as my sample application, which requires running the X-framebuffer (its a program that converts web kit pages to images and requires an X server).

+2
source

This is Python code, not a shell command line.

The shell command line uses quotation marks to store spaces - in Python, spaces are stored in different ways, so the quotes are passed as-is and become part of the argument that the program actually sees.

+1
source

All Articles