Пример #1
0
def get_env_debug_info(env_exe, debug_script, app_data, env):
    env = env.copy()
    env.pop(str("PYTHONPATH"), None)

    with app_data.ensure_extracted(debug_script) as debug_script:
        cmd = [str(env_exe), str(debug_script)]
        if WIN_CPYTHON_2:
            cmd = [ensure_text(i) for i in cmd]
        logging.debug(str("debug via %r"), LogCmd(cmd))
        code, out, err = run_cmd(cmd)

    # noinspection PyBroadException
    try:
        if code != 0:
            if out:
                result = literal_eval(out)
            else:
                if code == 2 and "file" in err:
                    # Re-raise FileNotFoundError from `run_cmd()`
                    raise OSError(err)
                raise Exception(err)
        else:
            result = json.loads(out)
        if err:
            result["err"] = err
    except Exception as exception:
        return {
            "out": out,
            "err": err,
            "returncode": code,
            "exception": repr(exception)
        }
    if "sys" in result and "path" in result["sys"]:
        del result["sys"]["path"][0]
    return result
Пример #2
0
 def create_via_sub_process(self):
     cmd = self.get_host_create_cmd()
     logging.info("using host built-in venv to create via %s",
                  " ".join(cmd))
     code, out, err = run_cmd(cmd)
     if code != 0:
         raise ProcessCallFailed(code, out, err, cmd)
Пример #3
0
def get_env_debug_info(env_exe, debug_script, app_data):
    env = os.environ.copy()
    env.pop(str("PYTHONPATH"), None)

    with ensure_file_on_disk(debug_script, app_data) as debug_script:
        cmd = [str(env_exe), str(debug_script)]
        if WIN_CPYTHON_2:
            cmd = [ensure_text(i) for i in cmd]
        logging.debug(str("debug via %r"), LogCmd(cmd))
        code, out, err = run_cmd(cmd)

    # noinspection PyBroadException
    try:
        if code != 0:
            result = literal_eval(out)
        else:
            result = json.loads(out)
        if err:
            result["err"] = err
    except Exception as exception:
        return {
            "out": out,
            "err": err,
            "returncode": code,
            "exception": repr(exception)
        }
    if "sys" in result and "path" in result["sys"]:
        del result["sys"]["path"][0]
    return result
Пример #4
0
def test_app_data_pinning(tmp_path):
    result = cli_run([ensure_text(str(tmp_path)), "--pip", "19.3.1", "--activators", "", "--seeder", "app-data"])
    code, out, err = run_cmd([str(result.creator.script("pip")), "list", "--disable-pip-version-check"])
    assert not code
    assert not err
    for line in out.splitlines():
        parts = line.split()
        if parts and parts[0] == "pip":
            assert parts[1] == "19.3.1"
            break
    else:
        assert not out
Пример #5
0
def test_run_fail(tmp_path):
    code, out, err = run_cmd([str(tmp_path)])
    assert err
    assert not out
    assert code