0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-13 19:21:50 +02:00

feature(vscode): support for controlling vscode from widgets

This commit is contained in:
2024-09-19 18:18:25 +02:00
parent 91260bb579
commit 923867947f
2 changed files with 10 additions and 1 deletions

View File

@ -49,11 +49,19 @@ class VSCodeEditor(WebsiteWidget):
This method starts the server for the VSCode editor in a subprocess.
"""
env = os.environ.copy()
env["BEC_Widgets_GUIID"] = self.gui_id
env["BEC_REDIS_HOST"] = self.client.connector.host
cmd = shlex.split(
f"code serve-web --port {self.port} --connection-token={self.token} --accept-server-license-terms"
)
self.process = subprocess.Popen(
cmd, text=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, preexec_fn=os.setsid
cmd,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
preexec_fn=os.setsid,
env=env,
)
os.set_blocking(self.process.stdout.fileno(), False)

View File

@ -52,6 +52,7 @@ def test_start_server(qtbot, mocked_client):
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
preexec_fn=os.setsid,
env=mock.ANY,
)
in mock_popen.mock_calls
)