Skip to content

Commit c71c85e

Browse files
authored
Adopt new request with configuration object (#23626)
1 parent 1439637 commit c71c85e

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { Disposable, EventEmitter, Event, Uri } from 'vscode';
4+
import { Disposable, EventEmitter, Event, Uri, workspace } from 'vscode';
55
import * as ch from 'child_process';
66
import * as path from 'path';
77
import * as rpc from 'vscode-jsonrpc/node';
@@ -113,20 +113,9 @@ class NativeGlobalPythonFinderImpl extends DisposableBase implements NativeGloba
113113
connection.onNotification('environment', (data: NativeEnvInfo) => {
114114
discovered.fire(data);
115115
}),
116-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
117-
connection.onNotification((method: string, data: any) => {
118-
console.log(method, data);
119-
}),
120-
connection.onNotification('exit', (time: number) => {
121-
traceInfo(`Native Python Finder completed after ${time}ms`);
122-
disposeStreams.dispose();
123-
completed.resolve();
124-
}),
125-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
126-
connection.onRequest((method: string, args: any) => {
127-
console.error(method, args);
128-
return 'HELLO THERE';
129-
}),
116+
// connection.onNotification((method: string, data: any) => {
117+
// console.log(method, data);
118+
// }),
130119
connection.onNotification('log', (data: NativeLog) => {
131120
switch (data.level) {
132121
case 'info':
@@ -163,10 +152,17 @@ class NativeGlobalPythonFinderImpl extends DisposableBase implements NativeGloba
163152
);
164153

165154
connection.listen();
166-
connection.sendRequest('initialize', { body: ['This is id', 'Another'], supported: true }).then((r) => {
167-
console.error(r);
168-
void connection.sendNotification('initialized');
169-
});
155+
connection
156+
.sendRequest<number>('refresh', {
157+
// Send configuration information to the Python finder.
158+
search_paths: (workspace.workspaceFolders || []).map((w) => w.uri.fsPath),
159+
conda_executable: undefined,
160+
})
161+
.then((durationInMilliSeconds: number) => {
162+
completed.resolve();
163+
traceInfo(`Native Python Finder took ${durationInMilliSeconds}ms to complete.`);
164+
})
165+
.catch((ex) => traceError('Error in Native Python Finder', ex));
170166

171167
return { completed: completed.promise, discovered: discovered.event };
172168
}

src/client/pythonEnvironments/base/locators/lowLevel/nativeLocator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ export class NativeLocator implements ILocator<BasicEnvInfo>, IDisposable {
125125
const arch = (data.arch || '').toLowerCase();
126126
const env: BasicEnvInfo = {
127127
kind: categoryToKind(data.category),
128-
executablePath: data.executable,
129-
envPath: data.prefix,
130-
version: parseVersion(data.version),
131-
name: data.name === '' ? undefined : data.name,
132-
displayName: data.displayName,
128+
executablePath: data.executable ? data.executable : '',
129+
envPath: data.prefix ? data.prefix : undefined,
130+
version: data.version ? parseVersion(data.version) : undefined,
131+
name: data.name ? data.name : '',
132+
displayName: data.displayName ? data.displayName : '',
133133
searchLocation: data.project ? Uri.file(data.project) : undefined,
134134
identifiedUsingNativeLocator: true,
135135
arch:

0 commit comments

Comments
 (0)