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

Check if file exists instead of launching it #15726

Merged
merged 2 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions news/2 Fixes/15725.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check if Python executable file exists instead of launching the Python process.
11 changes: 2 additions & 9 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

// eslint-disable-next-line camelcase
import * as child_process from 'child_process';
import * as path from 'path';
import * as fs from 'fs';
import {
ConfigurationChangeEvent,
ConfigurationTarget,
Expand All @@ -27,7 +27,6 @@ import { DEFAULT_INTERPRETER_SETTING, isTestExecution } from './constants';
import { DeprecatePythonPath } from './experiments/groups';
import { ExtensionChannels } from './insidersBuild/types';
import { IS_WINDOWS } from './platform/constants';
import * as internalPython from './process/internal/python';
import {
IAnalysisSettings,
IAutoCompleteSettings,
Expand Down Expand Up @@ -766,13 +765,7 @@ function getPythonExecutable(pythonPath: string): string {
}

function isValidPythonPath(pythonPath: string): boolean {
const [args, parse] = internalPython.isValid();
try {
const output = child_process.execFileSync(pythonPath, args, { encoding: 'utf8' });
return parse(output);
} catch (ex) {
return false;
}
return fs.existsSync(pythonPath);
}

function convertSettingTypeToLogLevel(setting: LoggingLevelSettingType | undefined): LogLevel | 'off' {
Expand Down