/usr/lib/python2.7/dist-packages/pyvirtualdisplay/xvfb.py is in python-pyvirtualdisplay 0.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | from easyprocess import EasyProcess
from pyvirtualdisplay.abstractdisplay import AbstractDisplay
import logging
log = logging.getLogger(__name__)
PROGRAM = 'Xvfb'
URL = None
PACKAGE = 'xvfb'
class XvfbDisplay(AbstractDisplay):
'''
Xvfb wrapper
Xvfb is an X server that can run on machines with no display
hardware and no physical input devices. It emulates a dumb
framebuffer using virtual memory.
'''
def __init__(self, size=(1024, 768), color_depth=24, bgcolor='black', fbdir=None):
'''
:param bgcolor: 'black' or 'white'
:param fbdir: If non-null, the virtual screen is memory-mapped
to a file in the given directory ('-fbdir' option)
'''
self.screen = 0
self.size = size
self.color_depth = color_depth
self.process = None
self.bgcolor = bgcolor
self.display = None
self.fbdir = fbdir
AbstractDisplay.__init__(self)
@classmethod
def check_installed(cls):
EasyProcess([PROGRAM, '-help'], url=URL,
ubuntu_package=PACKAGE).check_installed()
@property
def _cmd(self):
cmd = [
dict(black='-br', white='-wr')[self.bgcolor],
'-nolisten',
'tcp',
'-screen',
str(self.screen),
'x'.join(map(str, list(self.size) + [self.color_depth])),
self.new_display_var,
]
if self.fbdir:
cmd += ['-fbdir', self.fbdir]
return [PROGRAM] + cmd
|