Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work in progress: passing viewer port to python via command substitution in launch.json #38

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Dmytry
Copy link

@Dmytry Dmytry commented Nov 19, 2023

Launch.json used:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "args": ["--port", "${command:ocpCadViewer.port}"],
            "env": {"ocp_port": "${command:ocpCadViewer.port}"},
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}

Seems to work, the command is launched with --port 3939 as expected. May need some checks in case the viewer isn't running yet, and maybe even auto-starting the viewer when ocpCadViewer.port command is called.

@Dmytry
Copy link
Author

Dmytry commented Nov 19, 2023

Tested it some, works via environment variables, got 2 windows each with its own view without a problem. Probably would be good to have a button to auto add a launch configuration with the "env" line from above, but usable as it is now.

@bernhard-42
Copy link
Owner

Not sure I understand how --port can then be easily used with ín the client in set_port.
I think the environment variable approach is the easier one and would even work without launch.json, isn't it?

@Dmytry
Copy link
Author

Dmytry commented Nov 24, 2023

I think the environment variable still needs launch.json, that's where I set it from, the "env": {"ocp_port": "${command:ocpCadViewer.port}" line.

Not sure if there's any other good way to set it. I think it's usable as it is, the user would have to modify their launch.json . Later I may try to find how to add an option to create launch.json via the menu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants