How to use the pyvirtualdisplay.Display 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_examples.py View on Github external
def test_lowres():
        with Display():
            p = EasyProcess([python, "-m", "pyvirtualdisplay.examples.lowres"]).start()
            sleep(1)
            assert p.is_alive()
            p.stop()
github ponty / PyVirtualDisplay / tests / test_core.py View on Github external
def test_extra_args():
    # Unrecognized option
    d = Display(extra_args=["willcrash"])
    with pytest.raises(XStartError):
        d.start()

    with Display():
        # -c                     turns off key-click
        with Display(visible=True, extra_args=["-c"]) as d:
            assert d.is_alive()
        assert not d.is_alive()

        with XephyrDisplay(extra_args=["-c"]) as d:
            assert d.is_alive()
        assert not d.is_alive()
github ponty / PyVirtualDisplay / tests / test_core.py View on Github external
def test_disp():
    vd = Display().start()
    assert vd.is_alive()

    # d = Display(visible=True).start().sleep(2).stop()
    # .assertEquals(d.return_code, 0)

    d = Display(visible=False).start().stop()
    assert d.return_code == 0

    vd.stop()
    assert not vd.is_alive()
github The-Compiler / pytest-xvfb / pytest_xvfb.py View on Github external
def start(self):
        self._virtual_display = pyvirtualdisplay.Display(
            backend='xvfb', size=(self.width, self.height),
            color_depth=self.colordepth, use_xauth=self.xauth,
            extra_args=self.args)
        self._virtual_display.start()
        self.display = self._virtual_display.display
        assert self._virtual_display.is_alive()
github realsanjay / DomainRecon / EyeWitness.py View on Github external
def single_mode(self, cli_parsed):
        display = None
        if cli_parsed.web:
            create_driver = selenium_module.create_driver
            capture_host = selenium_module.capture_host
            if not cli_parsed.show_selenium:
                display = Display(visible=0, size=(1920, 1080))
                display.start()
        elif cli_parsed.headless:
            if not os.path.isfile('./EyeWitness/bin/phantomjs'):
                print(" [*] Error: You are missing your phantomjs binary!")
                print(" [*] Please run the setup script!")
                sys.exit(0)
            create_driver = phantomjs_module.create_driver
            capture_host = phantomjs_module.capture_host

        url = cli_parsed.single
        http_object = objects.HTTPTableObject()
        if cli_parsed.active_scan:
            http_object._active_scan = True
        http_object.remote_system = url
        http_object.set_paths(
            cli_parsed.d, 'baseline' if cli_parsed.cycle is not None else None)
github cmu-db / cmdbac / core / deployers / drupaldeployer.py View on Github external
browser = webdriver.PhantomJS()
            browser.get('http://127.0.0.1:{port}/install.php'.format(port = self.port))
            WebDriverWait(browser, WAIT_TIME_LONG).until(EC.presence_of_element_located((By.ID, 'content')))

            profiles = []
            for element in browser.find_elements_by_class_name('form-radio'):
                profiles.append(element.get_attribute('value'))

            browser.quit()

            return profiles


        try:
            from pyvirtualdisplay import Display
            display = Display(visible=0, size=(800, 600))
            display.start()

            profiles = get_all_profiles()
            profile = self.repo.repo_name()
            if not self.repo.name.startswith('drupal/'):
                if profile not in profiles:
                    profile = profiles[0]
            LOG.info('Profile: {}'.format(profile))

            browser = webdriver.PhantomJS()
            browser.get('http://127.0.0.1:{port}/install.php?profile={profile}&welcome=done&locale=en'.format(port = self.port, profile = profile))

            t = threading.Thread(target = check_drupal_status, args = (self, ))
            t.daemon = True
            t.start()
github 0x09AL / raven / modules / requester.py View on Github external
def __init__(self):
		display = Display(visible=0, size=(1600, 1024))
		display.start()
		self.driver = webdriver.Firefox()
		self.driver.delete_all_cookies()
github harvard-lil / perma / perma_web / perma / tasks.py View on Github external
warcprox_controller = WarcproxController(proxy, warc_writer_thread)
        warcprox_thread = threading.Thread(target=warcprox_controller.run_until_shutdown, name="warcprox", args=())
        warcprox_thread.start()

        print "WarcProx opened."

        # Helper function to get a url, via proxied requests.get(), in a way that is interruptable from other threads.
        # This should only be run from sub-threads.
        def get_url(url):
            request_thread = add_thread(thread_list, ProxiedRequestThread(proxy_address, url))
            request_thread.join()
            return request_thread.response, request_thread.response_exception

        # start virtual display
        if settings.CAPTURE_BROWSER != "PhantomJS":
            display = Display(visible=0, size=(1024, 800))
            display.start()

        # fetch page in the background
        progress += 1
        display_progress(progress, "Fetching target URL")
        browser = get_browser(settings.CAPTURE_USER_AGENT, proxy_address, proxy.ca.ca_file)
        browser.set_window_size(1024, 800)

        start_time = time.time()
        page_load_thread = threading.Thread(target=browser.get, args=(target_url,))  # returns after onload
        page_load_thread.start()
        page_load_thread.join(ONLOAD_EVENT_TIMEOUT)

        # wait until warcprox records a response that isn't a forward
        have_response = False
        while not have_response:
github LukeMurphey / splunk-web-input / src / bin / website_input_app / web_driver_client.py View on Github external
def get_display(cls, logger=None):

        # Start a display so that this works on headless hosts
        if not os.name == 'nt':
            try:
                display = Display(visible=0, size=(800, 600))
                display.start()

                return display
            except EasyProcessCheckInstalledError:
                if logger:
                    logger.warn("Failed to load the virtual display; the web-browser might not be able to run if this is a headless host")
            except Exception:
                if logger:
                    logger.exception("Failed to load the virtual display; the web-browser might not be able to run if this is a headless host")
github gabfr / work-around-the-world / dags / crawlers / angel_co.py View on Github external
def main():
    display = Display(visible=0, size=(1440, 900))
    display.start()

    options = Options()
    # options.headless = True
    options.add_argument("window-size=1920,1080")
    options.add_argument("disable-gpu")
    options.add_argument("disable-extensions")
    options.add_argument("proxy-server='direct://'")
    options.add_argument("proxy-bypass-list=*")
    options.add_argument("start-maximized")
    options.add_argument("no-sandbox")
    options.add_argument("disable-dev-shm-usage")

    driver = selenium_create_driver(options=options)
    driver.set_window_size(1440, 900)
    driver.maximize_window()