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)
Beispiel #2
0
 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)
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)
Beispiel #4
0
 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)
Beispiel #5
0
 def test_empty(self):
     disp = SmartDisplay(visible=0)
     proc = EasyProcess(sys.executable)
     f = disp.wrap(proc.wrap(disp.waitgrab))
     self.assertRaises(Exception, f)