I'm an trying to take a screenshot in the background using CutyCapt
My application is written in python and calls CutyCapt by running a subprocess.
Works locally (windows) just fine, but the CutyCapt.exe for windows does not require an x server. When I try to execute my code (via the python subprocess) on my ubuntu box, it barks about me not supplying a command to Xvfb. However, if I run the command on the box myself it works fine.
Command that works on box:
box$ xvfb-run --server-args="-screen 0, 1100x800x24" ./CutyCapt --url=http://www.google.com --out=temp.png
Python Code that fails:
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
Returned error:
xvfb-run: usage error: need a command to run
box$
Things I've tried: -using call instead of Popen -stripping the quote from the screen args -breaking the screen args up into a list -setting os.environ["DISPLAY"]=":0" before executing the subprocess
Do I need to break the xvfb process up from the CutyCapt command?
Any help would be greatly appreciated.
shell = True
, then the first argument toPopen
should be a string, not a list. Whenshell = False
(the default), the first argument should be a list. Have you tried it withshell = False
? – Ollieollissettings.PLATFORM
is not"linux"
, how isxvfb-run
getting appended toargs
? – Ollieollisimport shlex; args = shlex.split(''' xvfb-run --server-args="-screen 0, 1100x800x24" ./CutyCapt --url=http://www.google.com --out=temp.png ''')
. – Ollieollis