solorice/vscodium/extensions/ms-azuretools.vscode-docker-1.22.0/resources/python/launcher.py
2022-04-28 21:17:01 +03:00

23 lines
868 B
Python

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE.md in the project root for license information.
# This acts as a simple launcher for debugpy that only redirects the args to the actual launcher inside the container
import os, sys
dockerExePath = sys.argv[-2] # Docker EXE path is the second-to-last arg
containerId = sys.argv[-1] # Container id is the last arg
args = sys.argv[1:-2] # The remaining args will be given to the launcher
# If the adapterHost is only a port number, then append the default DNS name 'host.docker.internal'
adapterHost = args[0]
if adapterHost.isnumeric():
args[0] = 'host.docker.internal:' + adapterHost
dockerExecArgs = [dockerExePath, 'exec', '-d', containerId, 'python3', '/debugpy/launcher'] + args
command = ' '.join(dockerExecArgs)
print(command)
os.system(command)