Example #1
0
def force(backend_name, bbox, childprocess):
    backend_class = backend_dict[backend_name]
    if select_childprocess(childprocess, backend_class):
        log.debug('running "%s" in child process', backend_name)
        return childprocess_grab(backend_name, bbox)
    else:
        obj = backend_class()
        im = obj.grab(bbox)
        return im
Example #2
0
def _grab(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 childprocess_grab(_grab_simple, backend, bbox)
    else:
        return _grab_simple(backend, bbox, filename)
Example #3
0
def auto(bbox, childprocess):
    im = None
    for backend_class in backends(childprocess):
        backend_name = backend_class.name
        try:
            if select_childprocess(childprocess, backend_class):
                log.debug('running "%s" in child process', backend_name)
                im = childprocess_grab(backend_name, bbox)
            else:
                obj = backend_class()

                im = obj.grab(bbox)
            break
        except Exception:
            msg = traceback.format_exc()
            log.debug(msg)
    if not im:
        msg = "All backends failed!"
        raise FailedBackendError(msg)

    return im