mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
added try catch aroud the json parse and bypassing the err by logging… (#8166)
* added try catch aroud the json parse and bypassing the err by logging to console * updated error message with package info * updates to address PR comments * added package info and refactored the err logging * backslash update * refactored error method and added try for the entire method
This commit is contained in:
@@ -36,6 +36,7 @@ const msgSkipPythonInstall = localize('msgSkipPythonInstall', "Python already ex
|
||||
const msgWaitingForInstall = localize('msgWaitingForInstall', "Another Python installation is currently in progress. Waiting for it to complete.");
|
||||
function msgDependenciesInstallationFailed(errorMessage: string): string { return localize('msgDependenciesInstallationFailed', "Installing Notebook dependencies failed with error: {0}", errorMessage); }
|
||||
function msgDownloadPython(platform: string, pythonDownloadUrl: string): string { return localize('msgDownloadPython', "Downloading local python for platform: {0} to {1}", platform, pythonDownloadUrl); }
|
||||
function msgPackageRetrievalFailed(errorMessage: string): string { return localize('msgPackageRetrievalFailed', "Encountered an error when trying to retrieve list of installed packages: {0}", errorMessage); }
|
||||
|
||||
export class JupyterServerInstallation {
|
||||
public apiWrapper: ApiWrapper;
|
||||
@@ -519,15 +520,20 @@ export class JupyterServerInstallation {
|
||||
}
|
||||
|
||||
public async getInstalledPipPackages(): Promise<PythonPkgDetails[]> {
|
||||
try {
|
||||
let cmd = `"${this.pythonExecutable}" -m pip list --format=json`;
|
||||
let packagesInfo = await this.executeBufferedCommand(cmd);
|
||||
|
||||
let packagesResult: PythonPkgDetails[] = [];
|
||||
if (packagesInfo) {
|
||||
packagesResult = <PythonPkgDetails[]>JSON.parse(packagesInfo);
|
||||
}
|
||||
return packagesResult;
|
||||
}
|
||||
catch (err) {
|
||||
this.outputChannel.appendLine(msgPackageRetrievalFailed(utils.getErrorMessage(err)));
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public installPipPackages(packages: PythonPkgDetails[], useMinVersion: boolean): Promise<void> {
|
||||
if (!packages || packages.length === 0) {
|
||||
@@ -549,6 +555,7 @@ export class JupyterServerInstallation {
|
||||
}
|
||||
|
||||
public async getInstalledCondaPackages(): Promise<PythonPkgDetails[]> {
|
||||
try {
|
||||
let condaExe = this.getCondaExePath();
|
||||
let cmd = `"${condaExe}" list --json`;
|
||||
let packagesInfo = await this.executeBufferedCommand(cmd);
|
||||
@@ -563,6 +570,11 @@ export class JupyterServerInstallation {
|
||||
}
|
||||
return [];
|
||||
}
|
||||
catch (err) {
|
||||
this.outputChannel.appendLine(msgPackageRetrievalFailed(utils.getErrorMessage(err)));
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public installCondaPackages(packages: PythonPkgDetails[], useMinVersion: boolean): Promise<void> {
|
||||
if (!packages || packages.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user