Esempio n. 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
Esempio n. 2
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
Esempio n. 3
0
 def _execute(cmd, env):
     logging.debug("pip seed by running: %s", LogCmd(cmd, env))
     process = Popen(cmd, env=env)
     process.communicate()
     if process.returncode != 0:
         raise RuntimeError(f"failed seed with code {process.returncode}")
     return process
Esempio n. 4
0
 def run(self, creator):
     if not self.enabled:
         return
     with self.get_pip_install_cmd(
             creator.exe, creator.interpreter.version_release_str) as cmd:
         with pip_wheel_env_run(
                 creator.interpreter.version_release_str) as env:
             logging.debug("pip seed by running: %s", LogCmd(cmd, env))
             process = Popen(cmd, env=env)
             process.communicate()
     if process.returncode != 0:
         raise RuntimeError("failed seed with code {}".format(
             process.returncode))