forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
97 lines (81 loc) · 3.47 KB
/
types.ts
File metadata and controls
97 lines (81 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { ChildProcess, SpawnOptions as ChildProcessSpawnOptions } from 'child_process';
import { Observable } from 'rxjs/Observable';
import { CancellationToken, Uri } from 'vscode';
import { Architecture } from '../platform/types';
import { ExecutionInfo } from '../types';
import { EnvironmentVariables } from '../variables/types';
export const IBufferDecoder = Symbol('IBufferDecoder');
export interface IBufferDecoder {
decode(buffers: Buffer[], encoding: string): string;
}
export type Output<T extends string | Buffer> = {
source: 'stdout' | 'stderr';
out: T;
};
export type ObservableExecutionResult<T extends string | Buffer> = {
proc: ChildProcess;
out: Observable<Output<T>>;
};
// tslint:disable-next-line:interface-name
export type SpawnOptions = ChildProcessSpawnOptions & {
encoding?: string;
token?: CancellationToken;
mergeStdOutErr?: boolean;
throwOnStdErr?: boolean;
};
export type ExecutionResult<T extends string | Buffer> = {
stdout: T;
stderr?: T;
};
export interface IProcessService {
execObservable(file: string, args: string[], options?: SpawnOptions): ObservableExecutionResult<string>;
exec(file: string, args: string[], options?: SpawnOptions): Promise<ExecutionResult<string>>;
}
export const IProcessServiceFactory = Symbol('IProcessServiceFactory');
export interface IProcessServiceFactory {
create(resource?: Uri): Promise<IProcessService>;
}
export const IPythonExecutionFactory = Symbol('IPythonExecutionFactory');
export type ExecutionFactoryCreationOptions = {
resource?: Uri;
pythonPath?: string;
};
export interface IPythonExecutionFactory {
create(options: ExecutionFactoryCreationOptions): Promise<IPythonExecutionService>;
}
export type ReleaseLevel = 'alpha' | 'beta' | 'candidate' | 'final';
// tslint:disable-next-line:interface-name
export type PythonVersionInfo = [number, number, number, ReleaseLevel];
export type InterpreterInfomation = {
path: string;
version: string;
sysVersion: string;
architecture: Architecture;
version_info: PythonVersionInfo;
sysPrefix: string;
};
export const IPythonExecutionService = Symbol('IPythonExecutionService');
export interface IPythonExecutionService {
getInterpreterInformation(): Promise<InterpreterInfomation | undefined>;
getExecutablePath(): Promise<string>;
isModuleInstalled(moduleName: string): Promise<boolean>;
execObservable(args: string[], options: SpawnOptions): ObservableExecutionResult<string>;
execModuleObservable(moduleName: string, args: string[], options: SpawnOptions): ObservableExecutionResult<string>;
exec(args: string[], options: SpawnOptions): Promise<ExecutionResult<string>>;
execModule(moduleName: string, args: string[], options: SpawnOptions): Promise<ExecutionResult<string>>;
}
export class StdErrError extends Error {
constructor(message: string) {
super(message);
}
}
export interface IExecutionEnvironmentVariablesService {
getEnvironmentVariables(resource?: Uri): Promise<EnvironmentVariables | undefined>;
}
export const IPythonToolExecutionService = Symbol('IPythonToolRunnerService');
export interface IPythonToolExecutionService {
execObservable(executionInfo: ExecutionInfo, options: SpawnOptions, resource: Uri): Promise<ObservableExecutionResult<string>>;
exec(executionInfo: ExecutionInfo, options: SpawnOptions, resource: Uri): Promise<ExecutionResult<string>>;
}