本文整理汇总了Python中pyvirtualdisplay.smartdisplay.SmartDisplay.wrap方法的典型用法代码示例。如果您正苦于以下问题:Python SmartDisplay.wrap方法的具体用法?Python SmartDisplay.wrap怎么用?Python SmartDisplay.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvirtualdisplay.smartdisplay.SmartDisplay
的用法示例。
在下文中一共展示了SmartDisplay.wrap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_slowshot_wrap
# 需要导入模块: from pyvirtualdisplay.smartdisplay import SmartDisplay [as 别名]
# 或者: from pyvirtualdisplay.smartdisplay.SmartDisplay import wrap [as 别名]
def test_slowshot_wrap(self):
disp = SmartDisplay(visible=0)
py = path(__file__).parent / ('slowgui.py')
proc = EasyProcess('python ' + py)
f = disp.wrap(proc.wrap(disp.waitgrab))
img = f()
eq_(img is not None, True)
示例2: prog_shot
# 需要导入模块: from pyvirtualdisplay.smartdisplay import SmartDisplay [as 别名]
# 或者: from pyvirtualdisplay.smartdisplay.SmartDisplay import wrap [as 别名]
def prog_shot(cmd, f, wait, timeout, screen_size, visible, bgcolor, cwd=None):
'''start process in headless X and create screenshot after 'wait' sec.
Repeats screenshot until it is not empty if 'repeat_if_empty'=True.
wait: wait at least N seconds after first window is displayed,
it can be used to skip splash screen
:param enable_crop: True -> crop screenshot
:param wait: int
'''
disp = SmartDisplay(visible=visible, size=screen_size, bgcolor=bgcolor)
disp.pyscreenshot_backend = None
disp.pyscreenshot_childprocess = True
proc = EasyProcess(cmd, cwd=cwd)
def func():
try:
img = disp.waitgrab(timeout=timeout)
except DisplayTimeoutError as e:
raise DisplayTimeoutError(str(e) + ' ' + str(proc))
if wait:
proc.sleep(wait)
img = disp.grab()
return img
img = disp.wrap(proc.wrap(func))()
if img:
img.save(f)
return (proc.stdout, proc.stderr)
示例3: test_slowshot_timeout
# 需要导入模块: from pyvirtualdisplay.smartdisplay import SmartDisplay [as 别名]
# 或者: from pyvirtualdisplay.smartdisplay.SmartDisplay import wrap [as 别名]
def test_slowshot_timeout(self):
disp = SmartDisplay(visible=0)
py = path(__file__).parent / ('slowgui.py')
proc = EasyProcess('python ' + py)
f = disp.wrap(proc.wrap(lambda: disp.waitgrab(timeout=1)))
self.assertRaises(DisplayTimeoutError, f)
示例4: test_empty
# 需要导入模块: from pyvirtualdisplay.smartdisplay import SmartDisplay [as 别名]
# 或者: from pyvirtualdisplay.smartdisplay.SmartDisplay import wrap [as 别名]
def test_empty(self):
disp = SmartDisplay(visible=0)
proc = EasyProcess(sys.executable)
f = disp.wrap(proc.wrap(disp.waitgrab))
self.assertRaises(Exception, f)