示例#1
0
def test_speedtest():
    eq_(proc("pyscreenshot.check.speedtest").return_code, 0)
    eq_(
        proc("pyscreenshot.check.speedtest",
             ["--childprocess", "0"]).return_code, 0)
    eq_(
        proc("pyscreenshot.check.speedtest",
             ["--childprocess", "1"]).return_code, 0)
示例#2
0
def test_speedtest():
    assert proc("pyscreenshot.check.speedtest").return_code == 0
    assert (
        proc("pyscreenshot.check.speedtest", ["--childprocess", "0"]).return_code == 0
    )
    assert (
        proc("pyscreenshot.check.speedtest", ["--childprocess", "1"]).return_code == 0
    )
示例#3
0
def test_print_versions_no_path():
    path = os.environ["PATH"]
    os.environ["PATH"] = "xxx"
    try:
        assert proc("pyscreenshot.check.versions").return_code == 0
    finally:
        os.environ["PATH"] = path
示例#4
0
def childprocess_backend_version(backend):
    p = proc("pyscreenshot.cli.print_backend_version", [backend])
    if p.return_code != 0:
        log.warning(p)
        raise FailedBackendError(p)

    return p.stdout
示例#5
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 = proc(
            "pyscreenshot.check.speedtest",
            ["--childprocess", childprocess_param] + bboxpar + debugpar +
            backendpar,
        )
        print(p.stdout)
示例#6
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 = proc("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
示例#7
0
def test_showgrabfullscreen():
    assert proc("pyscreenshot.examples.showgrabfullscreen").return_code == 0
示例#8
0
def test_showgrabbox():
    assert proc("pyscreenshot.examples.showgrabbox").return_code == 0
示例#9
0
def test_print_versions():
    assert proc("pyscreenshot.check.versions").return_code == 0
示例#10
0
def test_showgrabfullscreen():
    eq_(proc("pyscreenshot.examples.showgrabfullscreen").return_code, 0)
示例#11
0
def test_showgrabbox():
    eq_(proc("pyscreenshot.examples.showgrabbox").return_code, 0)
示例#12
0
def test_print_versions():
    eq_(proc("pyscreenshot.check.versions").return_code, 0)