Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion autorest/jsonrpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# --------------------------------------------------------------------------
import contextlib
import os
import sys
import logging

from jsonrpc import dispatcher, JSONRPCResponseManager
Expand Down Expand Up @@ -53,7 +54,8 @@ def Process(plugin_name: str, session_id: str) -> bool:


def main() -> None:
if os.environ.get("AUTOREST_PYTHON_ATTACH_VSCODE_DEBUG", False):
debugger_specified = len(sys.argv) > 1 and sys.argv[1] == 'debug'
if debugger_specified or os.environ.get("AUTOREST_PYTHON_ATTACH_VSCODE_DEBUG", False):
try:
import ptvsd # pylint: disable=import-outside-toplevel
except ImportError:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"prepare": "node run-python3.js prepare.py",
"start": "node run-python3.js start.py",
"install": "node run-python3.js install.py"
"install": "node run-python3.js install.py",
"debug": "node run-python3.js start.py debug"
},
"repository": {
"type": "git",
Expand Down
6 changes: 5 additions & 1 deletion run-python3.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ const extension = require("@azure-tools/extension");
async function runPython3(scriptName) {
const command = ["python"];
await extension.updatePythonPath(command);
cp.execSync(command[0] + " " + scriptName, {
var commandLine = command[0] + " " + scriptName
if (process.argv[3] === 'debug') {
commandLine += " debug"
}
cp.execSync(commandLine, {
stdio: [0, 1, 2]
});
}
Expand Down
3 changes: 2 additions & 1 deletion start.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ def main():

env_builder = venv.EnvBuilder(with_pip=True)
venv_context = env_builder.ensure_directories(venv_path)
command = "debug" if (len(sys.argv) > 1 and sys.argv[1] == 'debug') else None

python_run(venv_context, "autorest.jsonrpc.server")
python_run(venv_context, "autorest.jsonrpc.server", command=command)

if __name__ == "__main__":
main()