Exemplo n.º 1
0
def childprocess_backend_version(backend):
    p = run_mod_as_subproc("pyscreenshot.cli.print_backend_version", [backend])
    if p.return_code != 0:
        log.warning(p)
        raise FailedBackendError(p)

    return p.stdout
Exemplo n.º 2
0
def run_all(n, childprocess_param, virtual_only=True, bbox=None):
    debug = True
    print("")
    print("n=%s" % n)
    print("------------------------------------------------------")

    if bbox:
        x1, y1, x2, y2 = map(str, bbox)
        bbox = ":".join(map(str, (x1, y1, x2, y2)))
        bboxpar = ["--bbox", bbox]
    else:
        bboxpar = []
    if debug:
        debugpar = ["--debug"]
    else:
        debugpar = []
    for x in ["default"] + pyscreenshot.backends():
        backendpar = ["--backend", x]
        # skip non X backends
        if virtual_only and x in novirt:
            continue
        p = run_mod_as_subproc(
            "pyscreenshot.check.speedtest",
            ["--childprocess", childprocess_param] + bboxpar + debugpar +
            backendpar,
        )
        print(p.stdout)
Exemplo n.º 3
0
def test_print_versions_no_path():
    path = os.environ["PATH"]
    os.environ["PATH"] = "xxx"
    try:
        assert run_mod_as_subproc(
            "pyscreenshot.check.versions").return_code == 0
    finally:
        os.environ["PATH"] = path
Exemplo n.º 4
0
def check_example(name):
    owd = os.getcwd()
    with TemporaryDirectory(prefix="pyscreenshot") as tmpdirname:
        try:
            os.chdir(tmpdirname)
            assert run_mod_as_subproc("pyscreenshot.examples." + name).return_code == 0
        finally:
            os.chdir(owd)
Exemplo n.º 5
0
def childprocess_grab(backend, bbox):
    with TemporaryDirectory(prefix="pyscreenshot") as tmpdirname:
        filename = os.path.join(tmpdirname, "screenshot.png")
        cmd = ["--filename", filename]
        if bbox:
            x1, y1, x2, y2 = map(str, bbox)
            bbox = ":".join(map(str, (x1, y1, x2, y2)))
            cmd += ["--bbox", bbox]
        if backend:
            cmd += ["--backend", backend]
        if log.isEnabledFor(logging.DEBUG):
            cmd += ["--debug"]

        p = run_mod_as_subproc("pyscreenshot.cli.grab", cmd)
        if p.return_code != 0:
            # log.debug(p)
            raise FailedBackendError(p)

        data = open(filename, "rb").read()
        data = codec[1](data)
        return data
Exemplo n.º 6
0
def test_speedtest():
    assert run_mod_as_subproc("pyscreenshot.check.speedtest").return_code == 0
    assert (run_mod_as_subproc("pyscreenshot.check.speedtest",
                               ["--childprocess", "0"]).return_code == 0)
    assert (run_mod_as_subproc("pyscreenshot.check.speedtest",
                               ["--childprocess", "1"]).return_code == 0)
Exemplo n.º 7
0
def test_print_versions():
    assert run_mod_as_subproc("pyscreenshot.check.versions").return_code == 0