How to use the pyvirtualdisplay.smartdisplay.SmartDisplay function in PyVirtualDisplay

To help you get started, we’ve selected a few PyVirtualDisplay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ponty / PyVirtualDisplay / tests / test_smart.py View on Github external
def test_slowshot_timeout():
    disp = SmartDisplay(visible=False)
    py = Path(__file__).parent / ("slowgui.py")
    proc = EasyProcess([python, py])
    with disp:
        with proc:
            with pytest.raises(DisplayTimeoutError):
                img = disp.waitgrab(timeout=1)
github web-animations / web-animations-js-legacy / tools / python / run-tests.py View on Github external
httpd_thread.daemon = True
httpd_thread.start()


# Start up a virtual display, useful for testing on headless servers.
# -----------------------------------------------------------------------------

VIRTUAL_SIZE = (1024, 2000)

# PhantomJS doesn't need a display
disp = None
if args.virtual and args.browser != "PhantomJS":
    from pyvirtualdisplay.smartdisplay import SmartDisplay

    try:
        disp = SmartDisplay(
            visible=0, bgcolor='black', size=VIRTUAL_SIZE).start()
        atexit.register(disp.stop)
    except:
        if disp:
            disp.stop()
        raise


# Start up the web browser and run the tests.
# ----------------------------------------------------------------------------

from selenium import webdriver
from selenium.common import exceptions as selenium_exceptions
from selenium.webdriver.common.keys import Keys as selenium_keys

driver_arguments = {}
github ponty / PyVirtualDisplay / tests / screenshot2.py View on Github external
from pyvirtualdisplay.smartdisplay import SmartDisplay

logging.basicConfig(level=logging.DEBUG)


backend1 = "wx"
backend2 = "wx"


with SmartDisplay(visible=False, bgcolor="black") as disp:
    disp.pyscreenshot_backend = backend1
    with EasyProcess("xmessage test1"):
        img1 = disp.waitgrab()

with SmartDisplay(visible=False, bgcolor="black") as disp:
    disp.pyscreenshot_backend = backend2
    with EasyProcess("xmessage test2"):
        img2 = disp.waitgrab()

img1.show()
img2.show()
github ponty / PyVirtualDisplay / pyvirtualdisplay / examples / screenshot1.py View on Github external
from easyprocess import EasyProcess

from pyvirtualdisplay.smartdisplay import SmartDisplay

if __name__ == "__main__":
    disp = SmartDisplay(visible=False, bgcolor="black").start()
    xmessage = EasyProcess(["xmessage","hello"]).start()
    img = disp.waitgrab()
    xmessage.stop()
    disp.stop()
    img.show()
github ponty / PyVirtualDisplay / doc / generate-doc.py View on Github external
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() as disp:
        with EasyProcess(cmd):
            img = disp.waitgrab()
            img.save(fname)
github ponty / PyVirtualDisplay / pyvirtualdisplay / examples / screenshot2.py View on Github external
from easyprocess import EasyProcess
from pyvirtualdisplay.smartdisplay import SmartDisplay

disp = SmartDisplay(visible=0, bgcolor='black')
func = disp.wrap(EasyProcess('xmessage hello').wrap(disp.waitgrab))
img=func()
img.show()
github o-o-overflow / chall-www / deployment / frontend.py View on Github external
# First, create the copy of the hard drive
    if DEBUG:
        print "creating the HD"

    # kill any previous binaries
    for proc in psutil.process_iter():
        if proc.name() == "previous":
            proc.kill()
        
    tar = tarfile.open(PRISTINE_HARD_DISK, 'r:gz')
    tar.extractall(ACTUAL_HARD_DISK_DIR)

    if DEBUG:
        print "done creating the HD"

    with pyvirtualdisplay.smartdisplay.SmartDisplay(visible=0, size=(1300, 900)) as v_display:
        if DEBUG:
            print v_display
            print v_display.display

        with easyprocess.EasyProcess(PREVIOUS_BINARY) as previous:

            time.sleep(.50)
            xdo = Xdo()

            done = False
            while not done:
                wins = xdo.search_windows('Previous')
                # check if alive
                if not previous.is_alive():
                    print "Error, couldn't boot emulator"
                    return
github ponty / PyVirtualDisplay / pyvirtualdisplay / examples / screenshot3.py View on Github external
"""
using :keyword:`with` statement
"""
from easyprocess import EasyProcess

from pyvirtualdisplay.smartdisplay import SmartDisplay

if __name__ == "__main__":
    with SmartDisplay(visible=False, bgcolor="black") as disp:
        with EasyProcess(["xmessage", "hello"]):
            img = disp.waitgrab()

    img.show()
github ponty / PyVirtualDisplay / doc / generate-doc.py View on Github external
def main():
    pls = []
    try:
        os.chdir("gen")
        for cmd, grab, bg in commands:
            with SmartDisplay() as disp:
                logging.info("======== cmd: %s", cmd)
                fname_base = cmd.replace(" ", "_")
                fname = fname_base + ".txt"
                # logging.info("cmd: %s", cmd)
                print("file name: %s" % fname)
                with open(fname, "w") as f:
                    f.write("$ " + cmd)
                    if bg:
                        p = EasyProcess(cmd).start()
                    else:
                        p = EasyProcess(cmd).call()
                        f.write(p.stdout)
                        f.write(p.stderr)
                    pls += [p]
                if grab:
                    png = fname_base + ".png"