本文整理汇总了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)
示例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())
示例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()
示例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)
示例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)
示例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()
示例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')
示例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()
示例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()
示例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()
示例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
示例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
示例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()
示例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