From ffa44e576d3e6704adfb698afa307d069f3347f3 Mon Sep 17 00:00:00 2001 From: Miljan Karadzic Date: Sun, 12 May 2013 22:46:01 +0200 Subject: [PATCH 1/2] Adding nolisten --- xvfbwrapper/xvfbwrapper.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xvfbwrapper/xvfbwrapper.py b/xvfbwrapper/xvfbwrapper.py index 61c6849..35b05e7 100644 --- a/xvfbwrapper/xvfbwrapper.py +++ b/xvfbwrapper/xvfbwrapper.py @@ -18,10 +18,11 @@ import time class Xvfb: - def __init__(self, width=800, height=680, colordepth=24): + def __init__(self, width=800, height=680, colordepth=24, nolisten=None): self.width = width self.height = height self.colordepth = colordepth + self.nolisten = nolisten self.proc = None if 'DISPLAY' in os.environ: @@ -35,6 +36,10 @@ class Xvfb: 'Xvfb', ':%d' % (self.vdisplay_num,), '-screen', '0', '%dx%dx%d' % (self.width, self.height, self.colordepth) ] + + if self.nolisten: + self.xvfb_cmd = self.xvfb_cmd + ['-nolisten', self.nolisten] + self.proc = subprocess.Popen(self.xvfb_cmd, stdout=open(os.devnull), stderr=open(os.devnull)) From 08928d0c20dd1fd828b80f33ae5afd0646744c84 Mon Sep 17 00:00:00 2001 From: Miljan Karadzic Date: Fri, 17 May 2013 17:41:32 +0200 Subject: [PATCH 2/2] Adding support for additional command line options --- xvfbwrapper/xvfbwrapper.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xvfbwrapper/xvfbwrapper.py b/xvfbwrapper/xvfbwrapper.py index 35b05e7..24055b5 100644 --- a/xvfbwrapper/xvfbwrapper.py +++ b/xvfbwrapper/xvfbwrapper.py @@ -18,11 +18,17 @@ import time class Xvfb: - def __init__(self, width=800, height=680, colordepth=24, nolisten=None): + def __init__(self, width=800, height=680, colordepth=24, **kwargs): self.width = width self.height = height self.colordepth = colordepth - self.nolisten = nolisten + + self.xvfb_cmd = [ + '-screen', '0', '%dx%dx%d' % (self.width, self.height, self.colordepth) + ] + + for key, value in kwargs.items(): + self.xvfb_cmd = self.xvfb_cmd + ["-%s" % key, value] self.proc = None if 'DISPLAY' in os.environ: @@ -32,13 +38,7 @@ class Xvfb: def start(self): self.vdisplay_num = self.search_for_free_display() - self.xvfb_cmd = [ - 'Xvfb', ':%d' % (self.vdisplay_num,), '-screen', '0', - '%dx%dx%d' % (self.width, self.height, self.colordepth) - ] - - if self.nolisten: - self.xvfb_cmd = self.xvfb_cmd + ['-nolisten', self.nolisten] + self.xvfb_cmd = ['Xvfb', ':%d' % self.vdisplay_num] + self.xvfb_cmd self.proc = subprocess.Popen(self.xvfb_cmd, stdout=open(os.devnull),