Skip to content

Commit 786de71

Browse files
committed
fixed 244
1 parent 7fe4d2d commit 786de71

1 file changed

Lines changed: 1 addition & 47 deletions

File tree

src/client/refactor/proxy.ts

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ export class RefactorProxy extends vscode.Disposable {
2222
private _commandResolve: (value?: any | PromiseLike<any>) => void;
2323
private _commandReject: (reason?: any) => void;
2424
private _initializeReject: (reason?: any) => void;
25-
static pythonPath: string;
2625
constructor(extensionDir: string, private pythonSettings: IPythonSettings, private workspaceRoot: string = vscode.workspace.rootPath) {
2726
super(() => { });
2827
this._extensionDir = extensionDir;
29-
vscode.workspace.onDidChangeConfiguration(() => {
30-
RefactorProxy.pythonPath = '';
31-
});
3228
}
3329

3430
dispose() {
@@ -49,9 +45,7 @@ export class RefactorProxy extends vscode.Disposable {
4945
}
5046
private sendCommand<T>(command: string, telemetryEvent: string): Promise<T> {
5147
let timer = new Delays();
52-
return this.pickValidPythonPath().then(pythonPath => {
53-
return this.initialize(pythonPath);
54-
}).then(() => {
48+
return this.initialize(this.pythonSettings.pythonPath).then(() => {
5549
return new Promise<T>((resolve, reject) => {
5650
this._commandResolve = resolve;
5751
this._commandReject = reject;
@@ -67,44 +61,6 @@ export class RefactorProxy extends vscode.Disposable {
6761
return Promise.reject(reason);
6862
});
6963
}
70-
71-
private pickValidPythonPath(): Promise<string> {
72-
if (RefactorProxy.pythonPath && RefactorProxy.pythonPath.length > 0) {
73-
return Promise.resolve(RefactorProxy.pythonPath);
74-
}
75-
76-
// First try what ever path we have in pythonRopePath
77-
let promiseReult = this.checkIfPythonVersionIs2(this.pythonSettings.pythonPath).then(() => {
78-
return this.pythonSettings.pythonPath;
79-
});
80-
81-
if (this.pythonSettings.pythonPath !== 'python') {
82-
promiseReult = promiseReult.catch(() => {
83-
// Now try to use the default 'python' executable (if any)
84-
return this.checkIfPythonVersionIs2('python').then(() => {
85-
return 'python';
86-
});
87-
});
88-
}
89-
90-
return promiseReult.catch(() => {
91-
// Now try to find 'python2.7' (this seems to work on a Mac)
92-
return this.checkIfPythonVersionIs2('python2.7').then(() => {
93-
return 'python2.7';
94-
});
95-
});
96-
}
97-
98-
private checkIfPythonVersionIs2(pythonPath: string): Promise<boolean> {
99-
return new Promise<boolean>((resolve, reject) => {
100-
child_process.execFile(pythonPath, ['-c', 'import sys;print(sys.version)'], null, (error, stdout, stderr) => {
101-
if (stdout.indexOf('2.') === 0) {
102-
return resolve(true);
103-
}
104-
reject(new Error(ROPE_PYTHON_VERSION));
105-
});
106-
});
107-
}
10864
private initialize(pythonPath: string): Promise<string> {
10965
return new Promise<any>((resolve, reject) => {
11066
this._initializeReject = reject;
@@ -120,8 +76,6 @@ export class RefactorProxy extends vscode.Disposable {
12076
let dataStr: string = data + '';
12177
if (!that._startedSuccessfully && dataStr.startsWith('STARTED')) {
12278
that._startedSuccessfully = true;
123-
// We know this works, hence keep tarck of this python path
124-
RefactorProxy.pythonPath = pythonPath;
12579
return resolve();
12680
}
12781
that.onData(data);

0 commit comments

Comments
 (0)