mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 01:25:38 -05:00
@@ -45,12 +45,12 @@ export class PackageManager {
|
||||
public init(): void {
|
||||
}
|
||||
|
||||
private get pythonExecutable(): string {
|
||||
return this._config.pythonExecutable;
|
||||
private async getPythonExecutable(): Promise<string> {
|
||||
return await this._config.getPythonExecutable(true);
|
||||
}
|
||||
|
||||
private get _rExecutable(): string {
|
||||
return this._config.rExecutable;
|
||||
private async getRExecutable(): Promise<string> {
|
||||
return await this._config.getRExecutable(true);
|
||||
}
|
||||
/**
|
||||
* Returns packageManageProviders
|
||||
@@ -123,7 +123,8 @@ export class PackageManager {
|
||||
if (!this._config.rEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!this._rExecutable) {
|
||||
let rExecutable = await this.getRExecutable();
|
||||
if (!rExecutable) {
|
||||
throw new Error(constants.rConfigError);
|
||||
}
|
||||
|
||||
@@ -139,7 +140,8 @@ export class PackageManager {
|
||||
if (!this._config.pythonEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!this.pythonExecutable) {
|
||||
let pythonExecutable = await this.getPythonExecutable();
|
||||
if (!pythonExecutable) {
|
||||
throw new Error(constants.pythonConfigError);
|
||||
}
|
||||
if (!requiredPackages || requiredPackages.length === 0) {
|
||||
@@ -177,7 +179,8 @@ export class PackageManager {
|
||||
|
||||
private async getInstalledPipPackages(): Promise<nbExtensionApis.IPackageDetails[]> {
|
||||
try {
|
||||
let cmd = `"${this.pythonExecutable}" -m pip list --format=json`;
|
||||
let pythonExecutable = await this.getPythonExecutable();
|
||||
let cmd = `"${pythonExecutable}" -m pip list --format=json`;
|
||||
let packagesInfo = await this._processService.executeBufferedCommand(cmd, undefined);
|
||||
let packagesResult: nbExtensionApis.IPackageDetails[] = [];
|
||||
if (packagesInfo && packagesInfo.indexOf(']') > 0) {
|
||||
@@ -196,23 +199,25 @@ export class PackageManager {
|
||||
}
|
||||
|
||||
private async installPipPackage(requirementFilePath: string): Promise<string> {
|
||||
let cmd = `"${this.pythonExecutable}" -m pip install -r "${requirementFilePath}"`;
|
||||
let pythonExecutable = await this.getPythonExecutable();
|
||||
let cmd = `"${pythonExecutable}" -m pip install -r "${requirementFilePath}"`;
|
||||
return await this._processService.executeBufferedCommand(cmd, this._outputChannel);
|
||||
}
|
||||
|
||||
private async installRPackage(model: PackageConfigModel): Promise<string> {
|
||||
let output = '';
|
||||
let cmd = '';
|
||||
let rExecutable = await this.getRExecutable();
|
||||
if (model.downloadUrl) {
|
||||
const packageFile = utils.getPackageFilePath(this._rootFolder, model.fileName || model.name);
|
||||
const packageExist = await utils.exists(packageFile);
|
||||
if (!packageExist) {
|
||||
await this._httpClient.download(model.downloadUrl, packageFile, this._outputChannel);
|
||||
}
|
||||
cmd = `"${this._rExecutable}" CMD INSTALL ${packageFile}`;
|
||||
cmd = `"${rExecutable}" CMD INSTALL ${packageFile}`;
|
||||
output = await this._processService.executeBufferedCommand(cmd, this._outputChannel);
|
||||
} else if (model.repository) {
|
||||
cmd = `"${this._rExecutable}" -e "install.packages('${model.name}', repos='${model.repository}')"`;
|
||||
cmd = `"${rExecutable}" -e "install.packages('${model.name}', repos='${model.repository}')"`;
|
||||
output = await this._processService.executeBufferedCommand(cmd, this._outputChannel);
|
||||
}
|
||||
return output;
|
||||
|
||||
@@ -84,7 +84,7 @@ export class SqlPythonPackageManageProvider extends SqlPackageManageProviderBase
|
||||
'pkgmanager = sqlmlutils.SQLPackageManager(connection)',
|
||||
pythonCommandScript
|
||||
];
|
||||
let pythonExecutable = this._config.pythonExecutable;
|
||||
let pythonExecutable = await this._config.getPythonExecutable(true);
|
||||
await this._processService.execScripts(pythonExecutable, scripts, [], this._outputChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ export class SqlRPackageManageProvider extends SqlPackageManageProviderBase impl
|
||||
`${rCommandScript}(connectionString = connection, pkgs, scope = "PUBLIC")`,
|
||||
'q()'
|
||||
];
|
||||
let rExecutable = this._config.rExecutable;
|
||||
let rExecutable = await this._config.getRExecutable(true);
|
||||
await this._processService.execScripts(`${rExecutable}`, scripts, ['--vanilla'], this._outputChannel);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user