def _grab(to_file, childprocess=True, backend=None, bbox=None, filename=None): if childprocess: log.debug('running "%s" in child process', backend) return run_in_childprocess(_grab_simple, imcodec.codec, to_file, backend, bbox, filename) else: return _grab_simple(to_file, backend, bbox, filename)
def backend_version(backend, childprocess=True): '''Back-end version :param backend: back-end (examples:scrot, wx,..) :param childprocess: see :py:func:`grab` :return: version as string ''' if not childprocess: return _backend_version(backend) else: return run_in_childprocess(_backend_version, None, backend)
def _grab(to_file, childprocess, backend=None, bbox=None, filename=None): if bbox: x1, y1, x2, y2 = bbox if x2 <= x1: raise ValueError('bbox x2<=x1') if y2 <= y1: raise ValueError('bbox y2<=y1') if childprocess: log.debug('running "%s" in child process', backend) return run_in_childprocess( _grab_simple, imcodec.codec, to_file, backend, bbox, filename) else: return _grab_simple(to_file, backend, bbox, filename)
def backend_version(backend, childprocess=None): """Back-end version. :param backend: back-end (examples:scrot, wx,..) :param childprocess: see :py:func:`grab` :return: version as string """ if childprocess is None: childprocess = childprocess_default_value() if not childprocess: return _backend_version(backend) else: return run_in_childprocess(_backend_version, None, backend)
def test(): eq_(3, run_in_childprocess(lambda: 3)) eq_(4, run_in_childprocess(lambda x: 3 + x, None, 1)) eq_(5, run_in_childprocess(lambda x: 3 + x, None, x=2))
def test_exc(): eq_(3, run_in_childprocess(exc))
def test_codec(): coder = decoder = lambda x: x + 4 eq_(12, run_in_childprocess(lambda x: 3 + x, (coder, decoder), 1))
def _grab(to_file, childprocess=True, backend=None, bbox=None, filename=None, timeout=20): if childprocess: log.debug('running "%s" in child process', backend) return run_in_childprocess(_grab_simple, imcodec.codec, to_file, backend, bbox, filename, timeout=timeout) else: return _grab_simple(to_file, backend, bbox, filename)
def childprocess_grab(_grab_simple, backend, bbox): if POPEN: return childprocess_grab_popen(backend, bbox) else: return run_in_childprocess(_grab_simple, codec, backend, bbox)
def childprocess_backend_version(_backend_version, backend): if POPEN: return childprocess_backend_version_popen(backend) else: return run_in_childprocess(_backend_version, None, backend)
def test_codec(): coder = decoder = f4px eq_(12, run_in_childprocess(f3px, (coder, decoder), 1))
def test(): eq_(3, run_in_childprocess(f3)) eq_(4, run_in_childprocess(f3px, None, 1)) eq_(5, run_in_childprocess(f3px, None, x=2))
def _grab(to_file, childprocess=False, backend=None, bbox=None, filename=None): if childprocess: log.debug('running "%s" in child process', backend) return run_in_childprocess(_grab_simple, (_coder, _decoder), to_file, backend, bbox, filename) else: return _grab_simple(to_file, backend, bbox, filename)
def test_showgrabbox(): with Display(visible=0, size=(800, 600)): run_in_childprocess(target=showgrabbox_subprocess)
def test_showgrabfullscreen(): with Display(visible=0, size=(800, 600)): run_in_childprocess(target=showgrabfullscreen_subprocess)