コード例 #1
0
ファイル: __main__.py プロジェクト: leochan-star/lion
def main():
    from debugpy import launcher
    from debugpy.common import log
    from debugpy.launcher import debuggee

    log.to_file(prefix="debugpy.launcher")
    log.describe_environment("debugpy.launcher startup environment:")

    # Disable exceptions on Ctrl+C - we want to allow the debuggee process to handle
    # these, or not, as it sees fit. If the debuggee exits on Ctrl+C, the launcher
    # will also exit, so it doesn't need to observe the signal directly.
    signal.signal(signal.SIGINT, signal.SIG_IGN)

    def option(name, type, *args):
        try:
            return type(os.environ.pop(name, *args))
        except Exception:
            log.reraise_exception("Error parsing {0!r}:", name)

    launcher_port = option("DEBUGPY_LAUNCHER_PORT", int)

    launcher.connect(launcher_port)
    launcher.channel.wait()

    if debuggee.process is not None:
        sys.exit(debuggee.process.returncode)
コード例 #2
0
def main():
    from debugpy import launcher
    from debugpy.common import log
    from debugpy.launcher import debuggee

    log.to_file(prefix="debugpy.launcher")
    log.describe_environment("debugpy.launcher startup environment:")

    # Disable exceptions on Ctrl+C - we want to allow the debuggee process to handle
    # these, or not, as it sees fit. If the debuggee exits on Ctrl+C, the launcher
    # will also exit, so it doesn't need to observe the signal directly.
    signal.signal(signal.SIGINT, signal.SIG_IGN)

    # Everything before "--" is command line arguments for the launcher itself,
    # and everything after "--" is command line arguments for the debuggee.
    log.info("sys.argv before parsing: {0}", sys.argv)
    sep = sys.argv.index("--")
    launcher_argv = sys.argv[1:sep]
    sys.argv[:] = [sys.argv[0]] + sys.argv[sep + 1:]
    log.info("sys.argv after patching: {0}", sys.argv)

    # The first argument specifies the host/port on which the adapter is waiting
    # for launcher to connect. It's either host:port, or just port.
    adapter = launcher_argv[0]
    host, sep, port = adapter.partition(":")
    if not sep:
        host = "127.0.0.1"
        port = adapter
    port = int(port)

    launcher.connect(host, port)
    launcher.channel.wait()

    if debuggee.process is not None:
        sys.exit(debuggee.process.returncode)