Skip to content

Commit

Permalink
stdout check before setting flag
Browse files Browse the repository at this point in the history
Signed-off-by: Jitendra Gundaniya <[email protected]>
  • Loading branch information
jitu5 committed Sep 2, 2024
1 parent 32c6f17 commit 1c0365b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/common/callPythonScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { getInterpreterDetails } from './python';
* @param context - The context object.
* @returns A promise that resolves when the script execution is complete.
*/
export async function callPythonScript(pathToScript: string, scriptArgv: string, context: any): Promise<void> {
return new Promise<void>(async (resolve, reject) => {
export async function callPythonScript(pathToScript: string, scriptArgv: string, context: any): Promise<string> {
return new Promise<string>(async (resolve, reject) => {
const script = context.asAbsolutePath(pathToScript);
const interpreterDetails = await getInterpreterDetails();
const pythonPath = interpreterDetails['path'] && interpreterDetails['path'][0];
Expand All @@ -21,7 +21,7 @@ export async function callPythonScript(pathToScript: string, scriptArgv: string,
reject(error);
} else {
console.log(stdout);
resolve();
resolve(stdout);
}
});
});
Expand Down
11 changes: 7 additions & 4 deletions src/common/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ export async function installDependenciesIfNeeded(context: vscode.ExtensionConte
if (!alreadyInstalled) {
const pathToScript = 'bundled/tool/install_dependencies.py';
try {
await callPythonScript(pathToScript, EXTENSION_ROOT_DIR, context);
context.globalState.update('dependenciesInstalled', true);
const stdout = await callPythonScript(pathToScript, EXTENSION_ROOT_DIR, context);

traceLog(`Python dependencies installed!`);
console.log('Python dependencies installed!');
// Check if the script output contains the success message
if (stdout.includes('Successfully installed')) {
context.globalState.update('dependenciesInstalled', true);
traceLog(`Python dependencies installed!`);
console.log('Python dependencies installed!');
}
} catch (error) {
traceError(`Failed to install Python dependencies:: ${error}`);
console.error(`Failed to install Python dependencies:: ${error}`);
Expand Down

0 comments on commit 1c0365b

Please sign in to comment.