4

I have an argument in Python that is screwing up my subprocess() command. The argument is:

--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 it's escaping the double quotes. Is there a work around for this?

3
  • 1
    It doesn't look like it's escaping the double quotes to me. Commented Oct 14, 2010 at 22:38
  • this should be two distinct elements of the list, the same way -o and filename are different. Commented Oct 14, 2010 at 22:59
  • args = [ 'xvfb-run', '--server-args=', '"-screen=0, 1280x800x24"', '/usr/bin/python', '/root/AdamN-python-webkit2png-3ae4322/webkit2png.py', '-o', filename, 'google.com', ] /usr/bin/xvfb-run: line 173: "-screen=0, 1280x800x24": command not found Commented Oct 15, 2010 at 0:37

2 Answers 2

2

While you've probably figured this out in the past two years, I had this same problem today. The solution:

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'])

Assuming you have xvfb installed. I am using CutyCapt as my sample application that requires an X framebuffer to run (its a program that converts webkit pages to images and requires an X server).

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

Comments

1

This is Python code, not a shell command line.

A shell command line eats the quotes to keep the spaces - in Python, the spaces are kept by a different means, so the quotes are passed on as-is and become part of the argument the called program actually sees.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.