Running Xvfb and CutyCapt as a Python Subprocess

I am trying to take a screenshot in the background using CutyCapt

My application is written in python and calls CutyCapt by running a subprocess.

It works locally (windows) very well, but CutyCapt.exe for Windows does not require an x ​​server. When I try to execute my code (via the python subprocess) in my ubuntu block, it barks about me without delivering an Xvfb command. However, if I run the command on the box myself, it works fine.

The command that works in the field:

box$ xvfb-run --server-args="-screen 0, 1100x800x24" ./CutyCapt --url=http://www.google.com --out=temp.png

Failed to execute Python code:

def url_screengrab(url, **kwargs):
    url, temp_path, filename, url_hash = get_temp_screengrab_info(url)
    args = []
    if sys.platform.startswith("linux"):
        args.append('xvfb-run')
        args.append('--server-args="-screen 0, 1100x800x24"')
    args.append(settings.CUTYCAPT_EXE_PATH)
    args.append('--url=%s' % (url))
    args.append('--out=%s' % (temp_path,))
    subprocess.Popen(args, shell=False)
    return temp_path, filename, url_hash

Error returned:

xvfb-run: usage error: need a command to run
box$

, : - Popen - - -setting os.environ [ "DISPLAY" ] = ": 0"

xvfb CutyCapt?

.

+3
1

Ubuntu 11.10 cutycapt xvfb ( ...):

import shlex
import subprocess

def url_screengrab(url, **kwargs):
    cmd = '''xvfb-run --server-args "-screen 0, 1100x800x24"
             /usr/bin/cutycapt --url={u} --out=temp.png '''.format(u = url)
    proc = subprocess.Popen(shlex.split(cmd))
    proc.communicate()

url = 'http://www.google.com'
url_screengrab(url)
+5

All Articles