Adding support for additional command line options

This commit is contained in:
Miljan Karadzic 2013-05-17 17:41:32 +02:00
parent ffa44e576d
commit 08928d0c20
1 changed files with 9 additions and 9 deletions

View File

@ -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),