mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-30 01:25:38 -05:00
Check if python is running using powershell commands before doing install on Windows. (#6405)
This commit is contained in:
@@ -277,8 +277,20 @@ export class JupyterServerInstallation {
|
||||
};
|
||||
}
|
||||
|
||||
private isPythonRunning(pythonInstallPath: string): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
private async isPythonRunning(installPath: string, existingPython: boolean): Promise<boolean> {
|
||||
if (process.platform === constants.winPlatform) {
|
||||
let pythonExe = JupyterServerInstallation.getPythonExePath(installPath, existingPython);
|
||||
let cmd = `powershell.exe -NoProfile -Command "& {Get-Process python | Where-Object {$_.Path -eq '${pythonExe}'}}"`;
|
||||
let cmdResult: string;
|
||||
try {
|
||||
cmdResult = await this.executeBufferedCommand(cmd);
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
return cmdResult !== undefined && cmdResult.length > 0;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,7 +300,13 @@ export class JupyterServerInstallation {
|
||||
* The previous path (or the default) is used if a new path is not specified.
|
||||
*/
|
||||
public async startInstallProcess(forceInstall: boolean, installSettings?: { installPath: string, existingPython: boolean }): Promise<void> {
|
||||
let isPythonRunning = await this.isPythonRunning(installSettings ? installSettings.installPath : this._pythonInstallationPath);
|
||||
let isPythonRunning: boolean;
|
||||
if (installSettings) {
|
||||
isPythonRunning = await this.isPythonRunning(installSettings.installPath, installSettings.existingPython);
|
||||
} else {
|
||||
isPythonRunning = await this.isPythonRunning(this._pythonInstallationPath, this._usingExistingPython);
|
||||
}
|
||||
|
||||
if (isPythonRunning) {
|
||||
return Promise.reject(msgPythonRunningError);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user