Fix defaultInterpreterPath in vscode

This commit is contained in:
allegroai 2023-10-09 13:50:39 +03:00
parent f86e897e7e
commit 5a7423069c

View File

@ -379,6 +379,7 @@ def start_vscode_server(hostname, hostnames, param, task, env, bind_ip="127.0.0.
)
if user_folder:
# set user level configuration
settings = Path(os.path.expanduser(os.path.join(user_folder, 'User/settings.json')))
settings.parent.mkdir(parents=True, exist_ok=True)
# noinspection PyBroadException
@ -404,6 +405,27 @@ def start_vscode_server(hostname, hostnames, param, task, env, bind_ip="127.0.0.
except Exception:
pass
# set machine level configuration
settings = Path(os.path.expanduser(os.path.join(user_folder, 'Machine/settings.json')))
settings.parent.mkdir(parents=True, exist_ok=True)
# noinspection PyBroadException
try:
with open(settings.as_posix(), 'rt') as f:
base_json = json.load(f)
except Exception:
base_json = {}
# noinspection PyBroadException
try:
# "python.defaultInterpreterPath" is a machine level setting
base_json.update({
"python.defaultInterpreterPath": sys.executable,
})
with open(settings.as_posix(), 'wt') as f:
json.dump(base_json, f)
except Exception:
pass
proc = subprocess.Popen(
['bash', '-c',
'{} --auth none --bind-addr {}:{} --disable-update-check {} {}'.format(