PyVirtualDisplay-0.2.1/0000775000175000017500000000000012774510405014752 5ustar titititi00000000000000PyVirtualDisplay-0.2.1/setup.cfg0000664000175000017500000000007312774510405016573 0ustar titititi00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 PyVirtualDisplay-0.2.1/requirements.txt0000644000175000017500000000001612053442767020236 0ustar titititi00000000000000EasyProcess PyVirtualDisplay-0.2.1/README.rst0000664000175000017500000001175112774510046016447 0ustar titititi00000000000000pyvirtualdisplay is a python wrapper for Xvfb_, Xephyr_ and Xvnc_ Links: * home: https://github.com/ponty/pyvirtualdisplay * documentation: http://pyvirtualdisplay.readthedocs.org * PYPI: https://pypi.python.org/pypi/pyvirtualdisplay |Travis| |Coveralls| |Latest Version| |Supported Python versions| |License| |Downloads| |Code Health| |Documentation| Features: - python wrapper - supported python versions: 2.6, 2.7, 3.3, 3.4, 3.5 - back-ends: Xvfb_, Xephyr_, Xvnc_ .. warning:: at least one back-end should be installed Known problems: - only a few back-end options are supported Possible applications: * GUI testing * automatic GUI screenshot Basic usages ============ Start Xephyr:: from pyvirtualdisplay import Display xephyr=Display(visible=1, size=(320, 240)).start() Create screenshot of xmessage with Xvfb:: from easyprocess import EasyProcess from pyvirtualdisplay.smartdisplay import SmartDisplay with SmartDisplay(visible=0, bgcolor='black') as disp: with EasyProcess('xmessage hello'): img = disp.waitgrab() img.show() Installation ============ General ------- * install Xvfb_ or Xephyr_ or Xvnc_. * install pip_ * optional: pyscreenshot_ and PIL_ should be installed for ``smartdisplay`` submodule * install the program:: # as root pip install pyvirtualdisplay Ubuntu 14.04 ------------ :: sudo apt-get install python-pip sudo apt-get install xvfb xserver-xephyr vnc4server sudo pip install pyvirtualdisplay # optional sudo apt-get install python-pil scrot sudo pip install pyscreenshot # optional for examples sudo pip install entrypoint2 Uninstall --------- :: # as root pip uninstall pyvirtualdisplay Usage ===== .. #-- from docs.screenshot import screenshot--# .. #-# GUI Test -------- Testing ``gnumeric`` on low resolution:: #-- include('examples/lowres.py') --# from easyprocess import EasyProcess from pyvirtualdisplay import Display if __name__ == "__main__": Display(visible=1, size=(320, 240)).start() EasyProcess('gnumeric').start() #-# Image: .. #-- screenshot('python -m pyvirtualdisplay.examples.lowres','lowres.png') --# .. image:: _img/lowres.png .. #-# Screenshot ---------- Create screenshot of ``xmessage`` in background:: #-- include('examples/screenshot3.py') --# ''' using :keyword:`with` statement ''' from easyprocess import EasyProcess from pyvirtualdisplay.smartdisplay import SmartDisplay if __name__ == "__main__": with SmartDisplay(visible=0, bgcolor='black') as disp: with EasyProcess('xmessage hello'): img = disp.waitgrab() img.show() #-# Image: .. #-- screenshot('python -m pyvirtualdisplay.examples.screenshot3','screenshot3.png') --# .. image:: _img/screenshot3.png .. #-# vncserver --------- :: #-- include('examples/vncserver.py') --# ''' Example for Xvnc backend ''' from easyprocess import EasyProcess from pyvirtualdisplay.display import Display if __name__ == "__main__": with Display(backend='xvnc', rfbport=5904) as disp: with EasyProcess('xmessage hello') as proc: proc.wait() #-# xauth ===== Some programs require a functional Xauthority file. PyVirtualDisplay can generate one and set the appropriate environment variables if you pass ``use_xauth=True`` to the ``Display`` constructor. Note however that this feature needs ``xauth`` installed, otherwise a ``pyvirtualdisplay.xauth.NotFoundError`` is raised. .. _setuptools: http://peak.telecommunity.com/DevCenter/EasyInstall .. _pip: http://pip.openplans.org/ .. _Xvfb: http://en.wikipedia.org/wiki/Xvfb .. _Xephyr: http://en.wikipedia.org/wiki/Xephyr .. _pyscreenshot: https://github.com/ponty/pyscreenshot .. _PIL: http://www.pythonware.com/library/pil/ .. _Xvnc: http://www.hep.phy.cam.ac.uk/vnc_docs/xvnc.html .. |Travis| image:: http://img.shields.io/travis/ponty/PyVirtualDisplay.svg :target: https://travis-ci.org/ponty/PyVirtualDisplay/ .. |Coveralls| image:: http://img.shields.io/coveralls/ponty/PyVirtualDisplay/master.svg :target: https://coveralls.io/r/ponty/PyVirtualDisplay/ .. |Latest Version| image:: https://img.shields.io/pypi/v/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |Supported Python versions| image:: https://img.shields.io/pypi/pyversions/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |License| image:: https://img.shields.io/pypi/l/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |Downloads| image:: https://img.shields.io/pypi/dm/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |Code Health| image:: https://landscape.io/github/ponty/PyVirtualDisplay/master/landscape.svg?style=flat :target: https://landscape.io/github/ponty/PyVirtualDisplay/master .. |Documentation| image:: https://readthedocs.org/projects/pyvirtualdisplay/badge/?version=latest :target: http://pyvirtualdisplay.readthedocs.org PyVirtualDisplay-0.2.1/docs/0000775000175000017500000000000012774510405015702 5ustar titititi00000000000000PyVirtualDisplay-0.2.1/docs/conf.py0000664000175000017500000000223612666221244017204 0ustar titititi00000000000000import sys import os project = 'PyVirtualDisplay' author = 'ponty' copyright = '2011, ponty' __version__ = None exec(open(os.path.join('..', project.lower(), 'about.py')).read()) release = __version__ sys.path.insert(0, os.path.abspath('..')) # Extension extensions = [ # -*-Extensions: -*- 'sphinx.ext.autodoc', # 'sphinxcontrib.programoutput', # 'sphinxcontrib.programscreenshot', 'sphinx.ext.graphviz', #'sphinx.ext.autosummary', 'sphinx.ext.intersphinx', ] intersphinx_mapping = {'python': ('http://docs.python.org/', None)} # Source master_doc = 'index' templates_path = ['_templates'] source_suffix = '.rst' exclude_trees = [] pygments_style = 'sphinx' # html build settings html_theme = 'default' html_static_path = ['_static'] # htmlhelp settings htmlhelp_basename = '%sdoc' % project # latex build settings latex_documents = [ ('index', '%s.tex' % project, u'%s Documentation' % project, author, 'manual'), ] # remove blank pages from pdf # http://groups.google.com/group/sphinx- # dev/browse_thread/thread/92e19267d095412d/d60dcba483c6b13d latex_font_size = '10pt,oneside' latex_elements = dict( papersize='a4paper', ) PyVirtualDisplay-0.2.1/docs/screenshot.py0000664000175000017500000000113712666221244020433 0ustar titititi00000000000000from easyprocess import EasyProcess import os from pyvirtualdisplay.smartdisplay import SmartDisplay import cog import logging FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" logging.basicConfig(level=logging.DEBUG, format=FORMAT) def screenshot(cmd, fname): logging.info('%s %s',cmd, fname) fpath = 'docs/_img/%s' % fname if os.path.exists(fpath): os.remove(fpath) with SmartDisplay(visible=0, bgcolor='black') as disp: with EasyProcess(cmd): img = disp.waitgrab() img.save(fpath) cog.outl('.. image:: _img/%s' % fname) PyVirtualDisplay-0.2.1/docs/index.rst0000664000175000017500000000022012666221244017535 0ustar titititi00000000000000================ PyVirtualDisplay ================ About ===== .. include:: ../README.rst .. include:: struct.rst .. include:: api.rst PyVirtualDisplay-0.2.1/docs/api.rst0000664000175000017500000000025512666221244017207 0ustar titititi00000000000000API === .. autoclass:: pyvirtualdisplay.Display :members: start, stop .. autoclass:: pyvirtualdisplay.smartdisplay.SmartDisplay :members: :undoc-members: PyVirtualDisplay-0.2.1/docs/struct.rst0000644000175000017500000000142511713567753017772 0ustar titititi00000000000000Hierarchy ================================== .. graphviz:: digraph G { rankdir=LR; node [fontsize=8,style=filled, fillcolor=white]; fontsize=8; subgraph cluster_0 { label = "pyvirtualdisplay"; style=filled; subgraph cluster_2 { style=filled; fillcolor=white; label = "wrappers"; XvfbDisplay; XephyrDisplay; XvncDisplay; } Display -> XvfbDisplay; Display -> XephyrDisplay; Display -> XvncDisplay; SmartDisplay -> Display } XvfbDisplay -> Xvfb; XephyrDisplay -> Xephyr; XvncDisplay -> Xvnc; application -> Display; application -> SmartDisplay; SmartDisplay -> pyscreenshot; SmartDisplay -> PIL; } PyVirtualDisplay-0.2.1/docs/_img/0000775000175000017500000000000012774510405016615 5ustar titititi00000000000000PyVirtualDisplay-0.2.1/docs/_img/lowres.png0000664000175000017500000004253012666221244020642 0ustar titititi00000000000000PNG  IHDR@O*<EIDATxw`SwB!B"E)(OO">+ ?㉂ED(I$^DŽ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_K?u I + B(.4(OK_]QĢ,3\ !BuNu~ٽ =job՝CߑK"޿og{BP;_w3C4hUN% B`a?չܶbԭ];LρJNNZCǏkof>¢⸸{?mϲl)Ssl*)[_eb|΁0 /G={=°}v>tVVʪU / rnOnngGw.:[ř őq*Τ\}f.GGVvx\ݾh4}/޾42rX5g'S#p+xkkMnoCh^fG^dt^Ҳ!?2>ddTau/ r0cO=䂓'{hyK¤!s ="/-MJtIw-=GۯYmOa㊋<'ۣ@p=yǟ6!s?vУp|YB.ddfC, _?fDSO,)*.ddf3 !eʔ̞4r7U.w^F1۪L>miE\rN "`!!&poュ'Dcۗ7?ekx/NjoeȐ!{io//?/[ض9gVv@ :mOho/v޷{[3k7L@ O8E`^"lJKTjM{;B \Bv{" Q靻/%DXQ/X!mFxB."a `Э[01R  t0@h+G$&%Xno?KIENDB`PyVirtualDisplay-0.2.1/docs/_img/screenshot3.png0000664000175000017500000000077612666221244021575 0ustar titititi00000000000000PNG  IHDRG8 r\IDATxZ[  [sNQw-KbG&向N#"5p?w;O^?pUsޏ+!#+ԎkՀ]$(tt$&6U$)`z#=:8{B i늌jbuNDž !<~b]qˁ W]TLWhY[Z9 %V9qx.z}W>Ӫy]xCa=czY=>YS,g;$6shw9QT!4N"J&bJSZ J5@ "[X@XuZJ WTglH}vm G?jKKtiE~$@]{HK6~U-2ab;|O{zP}ZCˁB_i,l,|vc^VߺWuZr9çZ#IENDB`PyVirtualDisplay-0.2.1/docs/__init__.py0000664000175000017500000000000012666221244020001 0ustar titititi00000000000000PyVirtualDisplay-0.2.1/docs/.gitignore0000664000175000017500000000000412666221244017664 0ustar titititi00000000000000api PyVirtualDisplay-0.2.1/pyvirtualdisplay/0000775000175000017500000000000012774510405020377 5ustar titititi00000000000000PyVirtualDisplay-0.2.1/pyvirtualdisplay/xephyr.py0000664000175000017500000000212312321242124022252 0ustar titititi00000000000000from easyprocess import EasyProcess from pyvirtualdisplay.abstractdisplay import AbstractDisplay PROGRAM = 'Xephyr' URL = None PACKAGE = 'xephyr' class XephyrDisplay(AbstractDisplay): ''' Xephyr wrapper Xephyr is an X server outputting to a window on a pre-existing X display ''' def __init__(self, size=(1024, 768), color_depth=24, bgcolor='black'): ''' :param bgcolor: 'black' or 'white' ''' self.color_depth = color_depth self.size = size self.bgcolor = bgcolor self.screen = 0 self.process = None self.display = None AbstractDisplay.__init__(self) @classmethod def check_installed(cls): EasyProcess([PROGRAM, '-help'], url=URL, ubuntu_package=PACKAGE).check_installed() @property def _cmd(self): cmd = [PROGRAM, dict(black='-br', white='-wr')[self.bgcolor], '-screen', 'x'.join(map(str, list(self.size) + [self.color_depth])), self.new_display_var, ] return cmd PyVirtualDisplay-0.2.1/pyvirtualdisplay/abstractdisplay.py0000664000175000017500000001026412774510046024146 0ustar titititi00000000000000from easyprocess import EasyProcess import fnmatch import logging import os import time import tempfile from threading import Lock from pyvirtualdisplay import xauth mutex = Lock() log = logging.getLogger(__name__) # TODO: not perfect # randomize to avoid possible conflicts RANDOMIZE_DISPLAY_NR = False if RANDOMIZE_DISPLAY_NR: import random random.seed() MIN_DISPLAY_NR = 1000 USED_DISPLAY_NR_LIST=[] class AbstractDisplay(EasyProcess): ''' Common parent for Xvfb and Xephyr ''' def __init__(self, use_xauth=False): mutex.acquire() try: self.display = self.search_for_display() while self.display in USED_DISPLAY_NR_LIST: self.display+=1 USED_DISPLAY_NR_LIST.append(self.display) finally: mutex.release() if xauth and not xauth.is_installed(): raise xauth.NotFoundError() self.use_xauth = use_xauth self._old_xauth = None self._xauth_filename = None EasyProcess.__init__(self, self._cmd) @property def new_display_var(self): return ':%s' % (self.display) @property def _cmd(self): raise NotImplementedError() def lock_files(self): tmpdir = '/tmp' pattern = '.X*-lock' # ls = path('/tmp').files('.X*-lock') # remove path.py dependency names = fnmatch.filter(os.listdir(tmpdir), pattern) ls = [os.path.join(tmpdir, child) for child in names] ls = [p for p in ls if os.path.isfile(p)] return ls def search_for_display(self): # search for free display ls = map( lambda x: int(x.split('X')[1].split('-')[0]), self.lock_files()) if len(ls): display = max(MIN_DISPLAY_NR, max(ls) + 3) else: display = MIN_DISPLAY_NR if RANDOMIZE_DISPLAY_NR: display += random.randint(0, 100) return display def redirect_display(self, on): ''' on: * True -> set $DISPLAY to virtual screen * False -> set $DISPLAY to original screen :param on: bool ''' d = self.new_display_var if on else self.old_display_var if d is None: log.debug('unset DISPLAY') del os.environ['DISPLAY'] else: log.debug('DISPLAY=%s', d) os.environ['DISPLAY'] = d def start(self): ''' start display :rtype: self ''' if self.use_xauth: self._setup_xauth() EasyProcess.start(self) # https://github.com/ponty/PyVirtualDisplay/issues/2 # https://github.com/ponty/PyVirtualDisplay/issues/14 self.old_display_var = os.environ.get('DISPLAY', None) self.redirect_display(True) # wait until X server is active # TODO: better method time.sleep(0.1) return self def stop(self): ''' stop display :rtype: self ''' self.redirect_display(False) EasyProcess.stop(self) if self.use_xauth: self._clear_xauth() return self def _setup_xauth(self): ''' Set up the Xauthority file and the XAUTHORITY environment variable. ''' handle, filename = tempfile.mkstemp(prefix='PyVirtualDisplay.', suffix='.Xauthority') self._xauth_filename = filename os.close(handle) # Save old environment self._old_xauth = {} self._old_xauth['AUTHFILE'] = os.getenv('AUTHFILE') self._old_xauth['XAUTHORITY'] = os.getenv('XAUTHORITY') os.environ['AUTHFILE'] = os.environ['XAUTHORITY'] = filename cookie = xauth.generate_mcookie() xauth.call('add', self.new_display_var, '.', cookie) def _clear_xauth(self): ''' Clear the Xauthority file and restore the environment variables. ''' os.remove(self._xauth_filename) for varname in ['AUTHFILE', 'XAUTHORITY']: if self._old_xauth[varname] is None: del os.environ[varname] else: os.environ[varname] = self._old_xauth[varname] self._old_xauth = None PyVirtualDisplay-0.2.1/pyvirtualdisplay/smartdisplay.py0000664000175000017500000000525712666221244023476 0ustar titititi00000000000000from pyvirtualdisplay.display import Display from PIL import Image from PIL import ImageChops import logging import pyscreenshot import time log = logging.getLogger(__name__) # class DisplayError(Exception): # pass class DisplayTimeoutError(Exception): pass class SmartDisplay(Display): pyscreenshot_backend = None pyscreenshot_childprocess = True def autocrop(self, im): '''Crop borders off an image. :param im: Source image. :param bgcolor: Background color, using either a color tuple or a color name (1.1.4 only). :return: An image without borders, or None if there's no actual content in the image. ''' if im.mode != "RGB": im = im.convert("RGB") bg = Image.new("RGB", im.size, self.bgcolor) diff = ImageChops.difference(im, bg) bbox = diff.getbbox() if bbox: return im.crop(bbox) return None # no contents def grab(self, autocrop=True): try: # first try newer pyscreenshot version img = pyscreenshot.grab( childprocess=self.pyscreenshot_childprocess, backend=self.pyscreenshot_backend, ) except TypeError: # try older pyscreenshot version img = pyscreenshot.grab() if autocrop: img = self.autocrop(img) return img def waitgrab(self, timeout=60, autocrop=True, cb_imgcheck=None): '''start process and create screenshot. Repeat screenshot until it is not empty and cb_imgcheck callback function returns True for current screenshot. :param autocrop: True -> crop screenshot :param timeout: int :param cb_imgcheck: None or callback for testing img, True = accept img, False = reject img ''' t = 0 sleep_time = 0.3 # for fast windows repeat_time = 1 while 1: log.debug('sleeping %s secs' % str(sleep_time)) time.sleep(sleep_time) t += sleep_time img = self.grab(autocrop=autocrop) if img: if not cb_imgcheck: break if cb_imgcheck(img): break sleep_time = repeat_time repeat_time += 1 # progressive if t > timeout: msg = 'Timeout! elapsed time:%s timeout:%s ' % (t, timeout) raise DisplayTimeoutError(msg) break log.debug('screenshot is empty, next try..') assert img # if not img: # log.debug('screenshot is empty!') return img PyVirtualDisplay-0.2.1/pyvirtualdisplay/xvnc.py0000664000175000017500000000247012321242124021716 0ustar titititi00000000000000from easyprocess import EasyProcess from pyvirtualdisplay.abstractdisplay import AbstractDisplay import logging log = logging.getLogger(__name__) PROGRAM = 'Xvnc' URL = None PACKAGE = 'tightvncserver' class XvncDisplay(AbstractDisplay): ''' Xvnc wrapper ''' def __init__(self, size=(1024, 768), color_depth=24, bgcolor='black', rfbport=5900): ''' :param bgcolor: 'black' or 'white' :param rfbport: Specifies the TCP port on which Xvnc listens for connections from viewers (the protocol used in VNC is called RFB - "remote framebuffer"). The default is 5900 plus the display number. ''' self.screen = 0 self.size = size self.color_depth = color_depth self.process = None self.bgcolor = bgcolor self.display = None self.rfbport = rfbport AbstractDisplay.__init__(self) @classmethod def check_installed(cls): EasyProcess([PROGRAM, '-help'], url=URL, ubuntu_package=PACKAGE).check_installed() @property def _cmd(self): cmd = [PROGRAM, '-depth', str(self.color_depth), '-geometry', '%dx%d' % (self.size[0], self.size[1]), '-rfbport', str(self.rfbport), self.new_display_var, ] return cmd PyVirtualDisplay-0.2.1/pyvirtualdisplay/xauth.py0000664000175000017500000000134512774510046022106 0ustar titititi00000000000000'''Utility functions for xauth.''' import os import hashlib import easyprocess class NotFoundError(Exception): '''Error when xauth was not found.''' pass def is_installed(): ''' Return whether or not xauth is installed. ''' try: easyprocess.EasyProcess(['xauth', '-h']).check_installed() except easyprocess.EasyProcessCheckInstalledError: return False else: return True def generate_mcookie(): ''' Generate a cookie string suitable for xauth. ''' data = os.urandom(16) # 16 bytes = 128 bit return hashlib.md5(data).hexdigest() def call(*args): ''' Call xauth with the given args. ''' easyprocess.EasyProcess(['xauth'] + list(args)).call() PyVirtualDisplay-0.2.1/pyvirtualdisplay/__init__.py0000664000175000017500000000033012666221244022504 0ustar titititi00000000000000import logging from pyvirtualdisplay.display import Display from pyvirtualdisplay.about import __version__ log = logging.getLogger(__name__) log = logging.getLogger(__name__) log.debug('version=%s', __version__) PyVirtualDisplay-0.2.1/pyvirtualdisplay/xvfb.py0000664000175000017500000000303312666221244021715 0ustar titititi00000000000000from 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 PyVirtualDisplay-0.2.1/pyvirtualdisplay/about.py0000664000175000017500000000002612774510251022060 0ustar titititi00000000000000__version__ = '0.2.1' PyVirtualDisplay-0.2.1/pyvirtualdisplay/examples/0000775000175000017500000000000012774510405022215 5ustar titititi00000000000000PyVirtualDisplay-0.2.1/pyvirtualdisplay/examples/lowres.py0000664000175000017500000000027112666221244024102 0ustar titititi00000000000000from easyprocess import EasyProcess from pyvirtualdisplay import Display if __name__ == "__main__": Display(visible=1, size=(320, 240)).start() EasyProcess('gnumeric').start() PyVirtualDisplay-0.2.1/pyvirtualdisplay/examples/screenshot3.py0000664000175000017500000000050112666221244025023 0ustar titititi00000000000000''' using :keyword:`with` statement ''' from easyprocess import EasyProcess from pyvirtualdisplay.smartdisplay import SmartDisplay if __name__ == "__main__": with SmartDisplay(visible=0, bgcolor='black') as disp: with EasyProcess('xmessage hello'): img = disp.waitgrab() img.show() PyVirtualDisplay-0.2.1/pyvirtualdisplay/examples/vncserver.py0000664000175000017500000000042312666221244024603 0ustar titititi00000000000000''' Example for Xvnc backend ''' from easyprocess import EasyProcess from pyvirtualdisplay.display import Display if __name__ == "__main__": with Display(backend='xvnc', rfbport=5904) as disp: with EasyProcess('xmessage hello') as proc: proc.wait() PyVirtualDisplay-0.2.1/pyvirtualdisplay/examples/__init__.py0000644000175000017500000000000012107740667024317 0ustar titititi00000000000000PyVirtualDisplay-0.2.1/pyvirtualdisplay/examples/screenshot1.py0000664000175000017500000000046512666221244025032 0ustar titititi00000000000000from easyprocess import EasyProcess from pyvirtualdisplay.smartdisplay import SmartDisplay if __name__ == "__main__": disp = SmartDisplay(visible=0, bgcolor='black').start() xmessage = EasyProcess('xmessage hello').start() img = disp.waitgrab() xmessage.stop() disp.stop() img.show() PyVirtualDisplay-0.2.1/pyvirtualdisplay/display.py0000664000175000017500000000337012774510046022422 0ustar titititi00000000000000from pyvirtualdisplay.abstractdisplay import AbstractDisplay from pyvirtualdisplay.xephyr import XephyrDisplay from pyvirtualdisplay.xvfb import XvfbDisplay from pyvirtualdisplay.xvnc import XvncDisplay class Display(AbstractDisplay): ''' Common class :param color_depth: [8, 16, 24, 32] :param size: screen size (width,height) :param bgcolor: background color ['black' or 'white'] :param visible: True -> Xephyr, False -> Xvfb :param backend: 'xvfb', 'xvnc' or 'xephyr', ignores ``visible`` :param xauth: If a Xauthority file should be created. ''' def __init__(self, backend=None, visible=False, size=(1024, 768), color_depth=24, bgcolor='black', use_xauth=False, **kwargs): self.color_depth = color_depth self.size = size self.bgcolor = bgcolor self.screen = 0 self.process = None self.display = None self.visible = visible self.backend = backend if not self.backend: if self.visible: self.backend = 'xephyr' else: self.backend = 'xvfb' self._obj = self.display_class( size=size, color_depth=color_depth, bgcolor=bgcolor, **kwargs) AbstractDisplay.__init__(self, use_xauth=use_xauth) @property def display_class(self): assert self.backend if self.backend == 'xvfb': cls = XvfbDisplay if self.backend == 'xvnc': cls = XvncDisplay if self.backend == 'xephyr': cls = XephyrDisplay # TODO: check only once cls.check_installed() return cls @property def _cmd(self): self._obj.display = self.display return self._obj._cmd PyVirtualDisplay-0.2.1/PKG-INFO0000664000175000017500000001632412774510405016055 0ustar titititi00000000000000Metadata-Version: 1.1 Name: PyVirtualDisplay Version: 0.2.1 Summary: python wrapper for Xvfb, Xephyr and Xvnc Home-page: https://github.com/ponty/pyvirtualdisplay Author: ponty Author-email: UNKNOWN License: BSD Description: pyvirtualdisplay is a python wrapper for Xvfb_, Xephyr_ and Xvnc_ Links: * home: https://github.com/ponty/pyvirtualdisplay * documentation: http://pyvirtualdisplay.readthedocs.org * PYPI: https://pypi.python.org/pypi/pyvirtualdisplay |Travis| |Coveralls| |Latest Version| |Supported Python versions| |License| |Downloads| |Code Health| |Documentation| Features: - python wrapper - supported python versions: 2.6, 2.7, 3.3, 3.4, 3.5 - back-ends: Xvfb_, Xephyr_, Xvnc_ .. warning:: at least one back-end should be installed Known problems: - only a few back-end options are supported Possible applications: * GUI testing * automatic GUI screenshot Basic usages ============ Start Xephyr:: from pyvirtualdisplay import Display xephyr=Display(visible=1, size=(320, 240)).start() Create screenshot of xmessage with Xvfb:: from easyprocess import EasyProcess from pyvirtualdisplay.smartdisplay import SmartDisplay with SmartDisplay(visible=0, bgcolor='black') as disp: with EasyProcess('xmessage hello'): img = disp.waitgrab() img.show() Installation ============ General ------- * install Xvfb_ or Xephyr_ or Xvnc_. * install pip_ * optional: pyscreenshot_ and PIL_ should be installed for ``smartdisplay`` submodule * install the program:: # as root pip install pyvirtualdisplay Ubuntu 14.04 ------------ :: sudo apt-get install python-pip sudo apt-get install xvfb xserver-xephyr vnc4server sudo pip install pyvirtualdisplay # optional sudo apt-get install python-pil scrot sudo pip install pyscreenshot # optional for examples sudo pip install entrypoint2 Uninstall --------- :: # as root pip uninstall pyvirtualdisplay Usage ===== .. #-- from docs.screenshot import screenshot--# .. #-# GUI Test -------- Testing ``gnumeric`` on low resolution:: #-- include('examples/lowres.py') --# from easyprocess import EasyProcess from pyvirtualdisplay import Display if __name__ == "__main__": Display(visible=1, size=(320, 240)).start() EasyProcess('gnumeric').start() #-# Image: .. #-- screenshot('python -m pyvirtualdisplay.examples.lowres','lowres.png') --# .. image:: _img/lowres.png .. #-# Screenshot ---------- Create screenshot of ``xmessage`` in background:: #-- include('examples/screenshot3.py') --# ''' using :keyword:`with` statement ''' from easyprocess import EasyProcess from pyvirtualdisplay.smartdisplay import SmartDisplay if __name__ == "__main__": with SmartDisplay(visible=0, bgcolor='black') as disp: with EasyProcess('xmessage hello'): img = disp.waitgrab() img.show() #-# Image: .. #-- screenshot('python -m pyvirtualdisplay.examples.screenshot3','screenshot3.png') --# .. image:: _img/screenshot3.png .. #-# vncserver --------- :: #-- include('examples/vncserver.py') --# ''' Example for Xvnc backend ''' from easyprocess import EasyProcess from pyvirtualdisplay.display import Display if __name__ == "__main__": with Display(backend='xvnc', rfbport=5904) as disp: with EasyProcess('xmessage hello') as proc: proc.wait() #-# xauth ===== Some programs require a functional Xauthority file. PyVirtualDisplay can generate one and set the appropriate environment variables if you pass ``use_xauth=True`` to the ``Display`` constructor. Note however that this feature needs ``xauth`` installed, otherwise a ``pyvirtualdisplay.xauth.NotFoundError`` is raised. .. _setuptools: http://peak.telecommunity.com/DevCenter/EasyInstall .. _pip: http://pip.openplans.org/ .. _Xvfb: http://en.wikipedia.org/wiki/Xvfb .. _Xephyr: http://en.wikipedia.org/wiki/Xephyr .. _pyscreenshot: https://github.com/ponty/pyscreenshot .. _PIL: http://www.pythonware.com/library/pil/ .. _Xvnc: http://www.hep.phy.cam.ac.uk/vnc_docs/xvnc.html .. |Travis| image:: http://img.shields.io/travis/ponty/PyVirtualDisplay.svg :target: https://travis-ci.org/ponty/PyVirtualDisplay/ .. |Coveralls| image:: http://img.shields.io/coveralls/ponty/PyVirtualDisplay/master.svg :target: https://coveralls.io/r/ponty/PyVirtualDisplay/ .. |Latest Version| image:: https://img.shields.io/pypi/v/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |Supported Python versions| image:: https://img.shields.io/pypi/pyversions/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |License| image:: https://img.shields.io/pypi/l/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |Downloads| image:: https://img.shields.io/pypi/dm/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |Code Health| image:: https://landscape.io/github/ponty/PyVirtualDisplay/master/landscape.svg?style=flat :target: https://landscape.io/github/ponty/PyVirtualDisplay/master .. |Documentation| image:: https://readthedocs.org/projects/pyvirtualdisplay/badge/?version=latest :target: http://pyvirtualdisplay.readthedocs.org Keywords: Xvfb Xephyr X wrapper Platform: UNKNOWN Classifier: License :: OSI Approved :: BSD License Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 PyVirtualDisplay-0.2.1/PyVirtualDisplay.egg-info/0000775000175000017500000000000012774510405021731 5ustar titititi00000000000000PyVirtualDisplay-0.2.1/PyVirtualDisplay.egg-info/requires.txt0000664000175000017500000000001412774510404024323 0ustar titititi00000000000000EasyProcess PyVirtualDisplay-0.2.1/PyVirtualDisplay.egg-info/top_level.txt0000664000175000017500000000002112774510404024453 0ustar titititi00000000000000pyvirtualdisplay PyVirtualDisplay-0.2.1/PyVirtualDisplay.egg-info/dependency_links.txt0000664000175000017500000000000112774510404025776 0ustar titititi00000000000000 PyVirtualDisplay-0.2.1/PyVirtualDisplay.egg-info/PKG-INFO0000664000175000017500000001632412774510404023033 0ustar titititi00000000000000Metadata-Version: 1.1 Name: PyVirtualDisplay Version: 0.2.1 Summary: python wrapper for Xvfb, Xephyr and Xvnc Home-page: https://github.com/ponty/pyvirtualdisplay Author: ponty Author-email: UNKNOWN License: BSD Description: pyvirtualdisplay is a python wrapper for Xvfb_, Xephyr_ and Xvnc_ Links: * home: https://github.com/ponty/pyvirtualdisplay * documentation: http://pyvirtualdisplay.readthedocs.org * PYPI: https://pypi.python.org/pypi/pyvirtualdisplay |Travis| |Coveralls| |Latest Version| |Supported Python versions| |License| |Downloads| |Code Health| |Documentation| Features: - python wrapper - supported python versions: 2.6, 2.7, 3.3, 3.4, 3.5 - back-ends: Xvfb_, Xephyr_, Xvnc_ .. warning:: at least one back-end should be installed Known problems: - only a few back-end options are supported Possible applications: * GUI testing * automatic GUI screenshot Basic usages ============ Start Xephyr:: from pyvirtualdisplay import Display xephyr=Display(visible=1, size=(320, 240)).start() Create screenshot of xmessage with Xvfb:: from easyprocess import EasyProcess from pyvirtualdisplay.smartdisplay import SmartDisplay with SmartDisplay(visible=0, bgcolor='black') as disp: with EasyProcess('xmessage hello'): img = disp.waitgrab() img.show() Installation ============ General ------- * install Xvfb_ or Xephyr_ or Xvnc_. * install pip_ * optional: pyscreenshot_ and PIL_ should be installed for ``smartdisplay`` submodule * install the program:: # as root pip install pyvirtualdisplay Ubuntu 14.04 ------------ :: sudo apt-get install python-pip sudo apt-get install xvfb xserver-xephyr vnc4server sudo pip install pyvirtualdisplay # optional sudo apt-get install python-pil scrot sudo pip install pyscreenshot # optional for examples sudo pip install entrypoint2 Uninstall --------- :: # as root pip uninstall pyvirtualdisplay Usage ===== .. #-- from docs.screenshot import screenshot--# .. #-# GUI Test -------- Testing ``gnumeric`` on low resolution:: #-- include('examples/lowres.py') --# from easyprocess import EasyProcess from pyvirtualdisplay import Display if __name__ == "__main__": Display(visible=1, size=(320, 240)).start() EasyProcess('gnumeric').start() #-# Image: .. #-- screenshot('python -m pyvirtualdisplay.examples.lowres','lowres.png') --# .. image:: _img/lowres.png .. #-# Screenshot ---------- Create screenshot of ``xmessage`` in background:: #-- include('examples/screenshot3.py') --# ''' using :keyword:`with` statement ''' from easyprocess import EasyProcess from pyvirtualdisplay.smartdisplay import SmartDisplay if __name__ == "__main__": with SmartDisplay(visible=0, bgcolor='black') as disp: with EasyProcess('xmessage hello'): img = disp.waitgrab() img.show() #-# Image: .. #-- screenshot('python -m pyvirtualdisplay.examples.screenshot3','screenshot3.png') --# .. image:: _img/screenshot3.png .. #-# vncserver --------- :: #-- include('examples/vncserver.py') --# ''' Example for Xvnc backend ''' from easyprocess import EasyProcess from pyvirtualdisplay.display import Display if __name__ == "__main__": with Display(backend='xvnc', rfbport=5904) as disp: with EasyProcess('xmessage hello') as proc: proc.wait() #-# xauth ===== Some programs require a functional Xauthority file. PyVirtualDisplay can generate one and set the appropriate environment variables if you pass ``use_xauth=True`` to the ``Display`` constructor. Note however that this feature needs ``xauth`` installed, otherwise a ``pyvirtualdisplay.xauth.NotFoundError`` is raised. .. _setuptools: http://peak.telecommunity.com/DevCenter/EasyInstall .. _pip: http://pip.openplans.org/ .. _Xvfb: http://en.wikipedia.org/wiki/Xvfb .. _Xephyr: http://en.wikipedia.org/wiki/Xephyr .. _pyscreenshot: https://github.com/ponty/pyscreenshot .. _PIL: http://www.pythonware.com/library/pil/ .. _Xvnc: http://www.hep.phy.cam.ac.uk/vnc_docs/xvnc.html .. |Travis| image:: http://img.shields.io/travis/ponty/PyVirtualDisplay.svg :target: https://travis-ci.org/ponty/PyVirtualDisplay/ .. |Coveralls| image:: http://img.shields.io/coveralls/ponty/PyVirtualDisplay/master.svg :target: https://coveralls.io/r/ponty/PyVirtualDisplay/ .. |Latest Version| image:: https://img.shields.io/pypi/v/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |Supported Python versions| image:: https://img.shields.io/pypi/pyversions/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |License| image:: https://img.shields.io/pypi/l/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |Downloads| image:: https://img.shields.io/pypi/dm/PyVirtualDisplay.svg :target: https://pypi.python.org/pypi/PyVirtualDisplay/ .. |Code Health| image:: https://landscape.io/github/ponty/PyVirtualDisplay/master/landscape.svg?style=flat :target: https://landscape.io/github/ponty/PyVirtualDisplay/master .. |Documentation| image:: https://readthedocs.org/projects/pyvirtualdisplay/badge/?version=latest :target: http://pyvirtualdisplay.readthedocs.org Keywords: Xvfb Xephyr X wrapper Platform: UNKNOWN Classifier: License :: OSI Approved :: BSD License Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 PyVirtualDisplay-0.2.1/PyVirtualDisplay.egg-info/SOURCES.txt0000664000175000017500000000155512774510405023623 0ustar titititi00000000000000LICENSE.txt MANIFEST.in README.rst pavement.py requirements.txt setup.py PyVirtualDisplay.egg-info/PKG-INFO PyVirtualDisplay.egg-info/SOURCES.txt PyVirtualDisplay.egg-info/dependency_links.txt PyVirtualDisplay.egg-info/requires.txt PyVirtualDisplay.egg-info/top_level.txt docs/.gitignore docs/__init__.py docs/api.rst docs/conf.py docs/index.rst docs/screenshot.py docs/struct.rst docs/_img/lowres.png docs/_img/screenshot3.png pyvirtualdisplay/__init__.py pyvirtualdisplay/about.py pyvirtualdisplay/abstractdisplay.py pyvirtualdisplay/display.py pyvirtualdisplay/smartdisplay.py pyvirtualdisplay/xauth.py pyvirtualdisplay/xephyr.py pyvirtualdisplay/xvfb.py pyvirtualdisplay/xvnc.py pyvirtualdisplay/examples/__init__.py pyvirtualdisplay/examples/lowres.py pyvirtualdisplay/examples/screenshot1.py pyvirtualdisplay/examples/screenshot3.py pyvirtualdisplay/examples/vncserver.pyPyVirtualDisplay-0.2.1/pavement.py0000664000175000017500000000100312666221244017135 0ustar titititi00000000000000from path import Path from paver.doctools import cog, html from paver.easy import options from paver.options import Bunch from paver.setuputils import setup IMPORTS=[cog, html, setup] options( cog=Bunch( basedir='.', pattern='README.rst', includedir='pyvirtualdisplay', beginspec='#--', endspec='--#', endoutput='#-#', ) ) # get info from setup.py setup_py = ''.join( [x for x in Path('setup.py').lines() if 'setuptools' not in x]) exec(setup_py)PyVirtualDisplay-0.2.1/LICENSE.txt0000644000175000017500000000243511525024067016574 0ustar titititi00000000000000Copyright (c) 2011, ponty All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PyVirtualDisplay-0.2.1/MANIFEST.in0000664000175000017500000000026112322003542016473 0ustar titititi00000000000000graft docs include LICENSE* include pavement.py include TODO* include requirements.txt include versioneer.py include CHANGES* include README* include setup.py prune docs/_build PyVirtualDisplay-0.2.1/setup.py0000664000175000017500000000433012666221244016464 0ustar titititi00000000000000from setuptools import setup import os.path import sys if os.environ.get('distutils_issue8876_workaround_enabled', False): # sdist_hack: Remove reference to os.link to disable using hardlinks when # building setup.py's sdist target. This is done because # VirtualBox VMs shared filesystems don't support hardlinks. del os.link NAME = 'pyvirtualdisplay' PYPI_NAME = 'PyVirtualDisplay' URL = 'https://github.com/ponty/pyvirtualdisplay' DESCRIPTION = 'python wrapper for Xvfb, Xephyr and Xvnc' PACKAGES = [NAME, NAME + '.examples', ] # get __version__ __version__ = None exec(open(os.path.join(NAME, 'about.py')).read()) VERSION = __version__ extra = {} if sys.version_info >= (3,): extra['use_2to3'] = True extra['use_2to3_exclude_fixers'] = ['lib2to3.fixes.fix_import'] classifiers = [ # Get more strings from # http://www.python.org/pypi?%3Aaction=list_classifiers "License :: OSI Approved :: BSD License", "Natural Language :: English", 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', # "Programming Language :: Python :: 2.3", # "Programming Language :: Python :: 2.4", #"Programming Language :: Python :: 2.5", 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', # "Programming Language :: Python :: 2 :: Only", "Programming Language :: Python :: 3", # 'Programming Language :: Python :: 3.0', # "Programming Language :: Python :: 3.1", # 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', ] install_requires = ['EasyProcess'] setup( name=PYPI_NAME, version=VERSION, description=DESCRIPTION, long_description=open('README.rst', 'r').read(), classifiers=classifiers, keywords='Xvfb Xephyr X wrapper', author='ponty', # author_email='', url=URL, license='BSD', packages=PACKAGES, # include_package_data=True, # test_suite='nose.collector', # zip_safe=False, install_requires=install_requires, **extra )