forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
71 lines (56 loc) · 2.36 KB
/
types.ts
File metadata and controls
71 lines (56 loc) · 2.36 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { ChildProcess, SpawnOptions as ChildProcessSpawnOptions } from 'child_process';
import * as Rx from 'rxjs';
import { CancellationToken, Uri } from 'vscode';
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: Rx.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 const IProcessService = Symbol('IProcessService');
export interface IProcessService {
execObservable(file: string, args: string[], options: SpawnOptions): ObservableExecutionResult<string>;
exec(file: string, args: string[], options: SpawnOptions): Promise<ExecutionResult<string>>;
}
export const IPythonExecutionFactory = Symbol('IPythonExecutionFactory');
export interface IPythonExecutionFactory {
create(resource?: Uri): Promise<IPythonExecutionService>;
}
export const IPythonExecutionService = Symbol('IPythonExecutionService');
export interface IPythonExecutionService {
getVersion(): Promise<string>;
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>;
}