forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - Activate environment in terminal (#614)
Fixes #383
- Loading branch information
1 parent
df2b494
commit 0253995
Showing
55 changed files
with
2,581 additions
and
912 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { injectable } from 'inversify'; | ||
import * as path from 'path'; | ||
import { PythonInterpreter } from '../../../interpreter/contracts'; | ||
import { IServiceContainer } from '../../../ioc/types'; | ||
import { IFileSystem } from '../../platform/types'; | ||
import { TerminalShellType } from '../types'; | ||
import { ITerminalActivationCommandProvider } from '../types'; | ||
|
||
@injectable() | ||
export abstract class BaseActivationCommandProvider implements ITerminalActivationCommandProvider { | ||
constructor(protected readonly serviceContainer: IServiceContainer) { } | ||
|
||
public abstract isShellSupported(targetShell: TerminalShellType): boolean; | ||
public abstract getActivationCommands(interpreter: PythonInterpreter, targetShell: TerminalShellType): Promise<string[] | undefined>; | ||
|
||
protected async findScriptFile(interpreter: PythonInterpreter, scriptFileNames: string[]): Promise<string | undefined> { | ||
const fs = this.serviceContainer.get<IFileSystem>(IFileSystem); | ||
|
||
for (const scriptFileName of scriptFileNames) { | ||
// Generate scripts are found in the same directory as the interpreter. | ||
const scriptFile = path.join(path.dirname(interpreter.path), scriptFileName); | ||
const found = await fs.fileExistsAsync(scriptFile); | ||
if (found) { | ||
return scriptFile; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.