当前位置: 首页>>代码示例>>Python>>正文


Python xvfbwrapper.Xvfb方法代码示例

本文整理汇总了Python中xvfbwrapper.Xvfb方法的典型用法代码示例。如果您正苦于以下问题:Python xvfbwrapper.Xvfb方法的具体用法?Python xvfbwrapper.Xvfb怎么用?Python xvfbwrapper.Xvfb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xvfbwrapper的用法示例。


在下文中一共展示了xvfbwrapper.Xvfb方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_run

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def test_run(self):
        file = "mosinit.hoc"
        path = "models/interneuron_modelDB/"

        filepath = os.path.abspath(__file__)
        filedir = os.path.dirname(filepath)

        model = NeuronModel(file=file,
                            path=os.path.join(filedir, path),
                            logger_level="error")

        model_parameters = {"cap": 1.1, "Rm": 22000}

        # TODO uncomment for final version, works on travis
        # with Xvfb() as xvfb:
        #     model.run(**model_parameters) 
开发者ID:simetenn,项目名称:uncertainpy,代码行数:18,代码来源:test_models.py

示例2: test_parallel

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def test_parallel(self):
        path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            "models/interneuron_modelDB/")

        model = NeuronModel(path=path,
                            interpolate=True,
                            logger_level="error")

        parallel = Parallel(model=model)
        model_parameters = {"cap": 1.1, "Rm": 22000}

        with Xvfb() as xvfb:
            result = parallel.run(model_parameters)

        self.assertIn("NeuronModel", result.keys())

        self.assertIn("time", result["NeuronModel"].keys())
        self.assertIn("values", result["NeuronModel"].keys())
        self.assertIn("interpolation", result["NeuronModel"].keys()) 
开发者ID:simetenn,项目名称:uncertainpy,代码行数:21,代码来源:test_models.py

示例3: _start_internal

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def _start_internal(self):
    self._started = True
    # Signals
    for sig in (signal.SIGINT, signal.SIGQUIT, signal.SIGTERM):
      signal.signal(sig, self.stop)

    # Setup the browser & xvfb
    self.xvfb = xvfbwrapper.Xvfb(width=1024, height=768)
    self.xvfb.start()
    self.browser = webdriver.Chrome(executable_path=self._chromedriver_path)
    self._run_event.set()
    self._stop_event.clear()


    self._thread = threading.Thread(target=self._wrap_run)
    self._thread.start()
    try:
      while True:
        time.sleep(self._interval)
        self._run_event.set()
    except KeyboardInterrupt:
      print 'Saw CTRL-C, shutting down.'
      self.stop() 
开发者ID:Matir,项目名称:pwnableweb,代码行数:25,代码来源:client.py

示例4: start_virtual_display

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def start_virtual_display(self, width=1440, height=900,
                              colordepth=24, **kwargs):
        """Starts virtual display which will be
         destroyed after test execution will be end

        *Arguments:*
        - width: a width to be set in pixels
        - height: a height to be set in pixels
        - color_depth: a color depth to be used
        - kwargs: extra parameters

        *Example:*

        | Start Virtual Display |
        | Start Virtual Display | 1920 | 1080 |
        | Start Virtual Display | ${1920} | ${1080} | ${16} |
        """
        if self._display is None:
            logger.info("Using virtual display: '{0}x{1}x{2}'".format(
                        width, height, colordepth))

            self._display = Xvfb(int(width), int(height),
                                 int(colordepth), **kwargs)
            self._display.start()
            atexit.register(self._display.stop) 
开发者ID:drobota,项目名称:robotframework-xvfb,代码行数:27,代码来源:__init__.py

示例5: make_pdf_report

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def make_pdf_report(
        template_data,
        pdf_report_path):
    with tempfile.NamedTemporaryFile(mode='w', suffix='.html') as f:
        _make_report(template_data, f, 'templates/template.html')
        f.flush()

        options = {
            'zoom': 0.55,
            'margin-top': '20mm'
        }

        if sys.platform in ('linux', 'linux2'):
            # pdfkit uses wkhtmltopdf, which doesn't work on headless servers;
            # recommended workaround is to use xvfb, as documented here:
            # https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2037#issuecomment-62019521
            from xvfbwrapper import Xvfb
            logger.info('Running pdfkit inside xvfb wrapper')
            with Xvfb():
                pdfkit.from_file(f.name, pdf_report_path, options=options)

        else:
            pdfkit.from_file(f.name, pdf_report_path, options=options)
    logger.info('Wrote PDF report to %s', pdf_report_path) 
开发者ID:openvax,项目名称:vaxrank,代码行数:26,代码来源:report.py

示例6: setUp

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def setUp(self):
        if os.environ.get('INTEGRATION_TESTS', False):
            # Start a virtual display server for running the tests headless.
            if os.environ.get('SELENIUM_HEADLESS', False):
                self.vdisplay = xvfbwrapper.Xvfb(width=1280, height=720)
                self.vdisplay.start()
            # Start the Selenium webdriver and setup configuration.
            self.driver = webdriver.WebDriverWrapper()
            self.driver.maximize_window()
            self.conf = config.get_config()
            self.driver.implicitly_wait(self.conf.selenium.implicit_wait)
            self.driver.set_page_load_timeout(self.conf.selenium.page_timeout)
        else:
            msg = "The INTEGRATION_TESTS env variable is not set."
            raise self.skipException(msg)
        super(BaseTestCase, self).setUp() 
开发者ID:CiscoSystems,项目名称:avos,代码行数:18,代码来源:helpers.py

示例7: setUp

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def setUp(self):
        self.disp = Xvfb()
        self.disp.start()
        self.m = mpv.MPV(vo='x11') 
开发者ID:jaseg,项目名称:python-mpv,代码行数:6,代码来源:mpv-test.py

示例8: test_custom_stream

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def test_custom_stream(self):
        handler = mock.Mock()
        fail_mock = mock.Mock(side_effect=ValueError)
        stream_mock = mock.Mock()
        stream_mock.seek = mock.Mock(return_value=0)
        stream_mock.read = mock.Mock(return_value=b'')

        disp = Xvfb()
        disp.start()
        m = mpv.MPV(video=False)
        m.register_event_callback(handler)

        m.register_stream_protocol('pythonfail', fail_mock)

        @m.register_stream_protocol('pythonsuccess')
        def open_fn(uri):
            self.assertEqual(uri, 'pythonsuccess://foo')
            return stream_mock

        m.play('pythondoesnotexist://foo')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.LOADING_FAILED}})
        handler.reset_mock()

        m.play('pythonfail://foo')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.LOADING_FAILED}})
        handler.reset_mock()

        m.play('pythonsuccess://foo')
        m.wait_for_playback()
        stream_mock.seek.assert_any_call(0)
        stream_mock.read.assert_called()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.UNKNOWN_FORMAT}})

        m.terminate()
        disp.stop() 
开发者ID:jaseg,项目名称:python-mpv,代码行数:39,代码来源:mpv-test.py

示例9: test_xvfb

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def test_xvfb(self):
        vdisplay = Xvfb()
        vdisplay.start()
        display_var = ':{}'.format(vdisplay.new_display)
        self.assertEqual(display_var, os.environ['DISPLAY'])
        vdisplay.stop() 
开发者ID:Kaggle,项目名称:docker-python,代码行数:8,代码来源:test_xvfbwrapper.py

示例10: recorded_xvfb

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def recorded_xvfb(video_filename, **xvfb_args):
    with Xvfb(**xvfb_args):
        with PopenContext([
                'recordmydesktop',
                '--no-sound',
                '--no-frame',
                '--on-the-fly-encoding',
                '-o', video_filename], close_fds=True) as screencast_proc: 
            yield
            screencast_proc.terminate() 
开发者ID:productize,项目名称:kicad-automation-scripts,代码行数:12,代码来源:ui_automation.py

示例11: set_up

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def set_up():
    global browser
    global xvfb
    xvfb = Xvfb(width=1280, height=720, colordepth=24)
    xvfb.start()
    browser = webdriver.Chrome()
    print browser.title
    print ':%d' % xvfb.vdisplay_num 
开发者ID:grayleonard,项目名称:xvfb-record,代码行数:10,代码来源:login.py

示例12: __init__

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def __init__(self, browser, log_file, unit_id, treatment_id, headless=False, proxy=None):
        self.headless = headless
        if(headless):
            from xvfbwrapper import Xvfb
            self.vdisplay = Xvfb(width=1280, height=720)
            self.vdisplay.start()
#           if(not self.vdisplay.start()):
#               fo = open(log_file, "a")
#               fo.write(str(datetime.now())+"||"+'error'+"||"+'Xvfb failure'+"||"+'failed to start'+"||"+str(unit_id)+"||"+str(treatment_id) + '\n')
#               fo.close()
#               sys.exit(0)
        if(proxy != None):
            sproxy = Proxy({
                'proxyType': ProxyType.MANUAL,
                'httpProxy': proxy,
                'ftpProxy': proxy,
                'sslProxy': proxy,
                'noProxy': '' # set this value as desired
                })
        else:
            sproxy = Proxy({
                'proxyType': ProxyType.MANUAL
                })
            
        if(browser=='firefox'):
            if (platform.system()=='Darwin'):
                self.driver = webdriver.Firefox(proxy=sproxy)
            elif (platform.system()=='Linux'):
                self.driver = webdriver.Firefox(proxy=sproxy)
            else:
                print "Unidentified Platform"
                sys.exit(0)
        elif(browser=='chrome'):
            print "Expecting chromedriver at path specified in core/web/browser_unit"
            if (platform.system()=='Darwin'):
                chromedriver = "../core/web/chromedriver/chromedriver_mac"
            elif (platform.system() == 'Linux'):
                chromedriver = "../core/web/chromedriver/chromedriver_linux"
            else:
                print "Unidentified Platform"
                sys.exit(0)
            os.environ["webdriver.chrome.driver"] = chromedriver
            chrome_option = webdriver.ChromeOptions()
            if(proxy != None):
                chrome_option.add_argument("--proxy-server="+proxy)
            self.driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chrome_option)
        else:
            print "Unsupported Browser"
            sys.exit(0)
        self.base_url = "https://www.google.com/"
        self.verificationErrors = []
        self.driver.set_page_load_timeout(40)
        self.accept_next_alert = True
        self.log_file = log_file
        self.unit_id = unit_id
        self.treatment_id = treatment_id 
开发者ID:tadatitam,项目名称:info-flow-experiments,代码行数:58,代码来源:browser_unit.py

示例13: test_python_stream

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def test_python_stream(self):
        handler = mock.Mock()

        disp = Xvfb()
        disp.start()
        m = mpv.MPV()
        m.register_event_callback(handler)

        @m.python_stream('foo')
        def foo_gen():
            with open(TESTVID, 'rb') as f:
                yield f.read()

        @m.python_stream('bar')
        def bar_gen():
            yield b''

        m.play('python://foo')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.EOF, 'error': mpv.ErrorCode.SUCCESS}})
        handler.reset_mock()

        m.play('python://bar')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.UNKNOWN_FORMAT}})
        handler.reset_mock()

        m.play('python://baz')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.LOADING_FAILED}})
        handler.reset_mock()

        m.play('foo://foo')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.LOADING_FAILED}})
        handler.reset_mock()

        foo_gen.unregister()

        m.play('python://foo')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.LOADING_FAILED}})
        handler.reset_mock()

        m.play('python://bar')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.UNKNOWN_FORMAT}})
        handler.reset_mock()

        m.terminate()
        disp.stop() 
开发者ID:jaseg,项目名称:python-mpv,代码行数:53,代码来源:mpv-test.py

示例14: run_drc

# 需要导入模块: import xvfbwrapper [as 别名]
# 或者: from xvfbwrapper import Xvfb [as 别名]
def run_drc(pcb_file, output_dir, record=True):

    file_util.mkdir_p(output_dir)

    recording_file = os.path.join(output_dir, 'run_drc_screencast.ogv')
    drc_output_file = os.path.join(os.path.abspath(output_dir), 'drc_result.rpt')

    xvfb_kwargs = {
	    'width': 800,
	    'height': 600,
	    'colordepth': 24,
    }

    with recorded_xvfb(recording_file, **xvfb_kwargs) if record else Xvfb(**xvfb_kwargs):
        with PopenContext(['pcbnew', pcb_file], close_fds=True) as pcbnew_proc:
            clipboard_store(drc_output_file)

            window = wait_for_window('pcbnew', 'Pcbnew', 10, False)

            logger.info('Focus main pcbnew window')
            wait_for_window('pcbnew', 'Pcbnew')

            # Needed to rebuild the menu, making sure it is actually built
            xdotool(['windowsize', '--sync', window, '750', '600'])

            wait_for_window('pcbnew', 'Pcbnew')

            logger.info('Open Inspect->DRC')
            xdotool(['key', 'alt+i', 'd'])

            logger.info('Focus DRC modal window')
            wait_for_window('DRC modal window', 'DRC Control')
            xdotool(['key',
                'Tab',
                'Tab',
                'Tab', # Refill zones on DRC gets saved in /root/.config/kicad/pcbnew as RefillZonesBeforeDrc
                'key',
                'Tab',
                'space', # Enable reporting all errors for tracks
                'Tab',
                'Tab',
                'Tab',
                'space',
                'Tab'
            ])
            logger.info('Pasting output dir')
            xdotool(['key', 'ctrl+v'])

            xdotool(['key', 'Return'])

            wait_for_window('Report completed dialog', 'Disk File Report Completed')
            xdotool(['key', 'Return'])
            pcbnew_proc.terminate()

    return drc_output_file 
开发者ID:productize,项目名称:kicad-automation-scripts,代码行数:57,代码来源:run_drc.py


注:本文中的xvfbwrapper.Xvfb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。