forked from Submersible/node-python-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
59 lines (51 loc) · 1.63 KB
/
index.d.ts
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
interface pythonBridge extends Function {
(options?: PythonBridgeOptions): PythonBridge;
}
export const pythonBridge: pythonBridge
export interface PythonBridgeOptions {
python?: string;
stdio?: [PipeStdin, PipeStdout, PipeStderr];
cwd?: string;
env?: { [key: string]: string | undefined; };
uid?: number;
gid?: number;
}
export interface PythonBridge {
(literals: TemplateStringsArray | string, ...placeholders: any[]): Bluebird.Promise<any>;
ex(literals: TemplateStringsArray | string, ...placeholders: any[]): Bluebird.Promise<void>;
lock<T>(withLock: (python: PythonBridge) => Promise<T>): Bluebird.Promise<T>
pid: number;
end(): Promise<void>;
disconnect(): Promise<void>;
kill(signal: string | number): void;
stdin: NodeJS.WritableStream;
stdout: NodeJS.ReadableStream;
stderr: NodeJS.ReadableStream;
connected: boolean;
}
export function isPythonException(name: string): (e: any) => boolean;
export function isPythonException(name: string, e: any): boolean;
export class PythonException extends Error {
exception: {
message: string;
args: any[];
type: { name: string; module: string; }
format: string[];
};
traceback: {
lineno: number;
strack: string[];
format: string[]
};
format: string[]
}
export type Pipe = "pipe" | "ignore" | "inherit";
export type PipeStdin = Pipe | NodeJS.ReadableStream;
export type PipeStdout = Pipe | NodeJS.WritableStream;
export type PipeStderr = Pipe | NodeJS.WritableStream;
export namespace Bluebird {
interface Promise<T> extends _Promise<T> {
timeout(milliseconds: number): Bluebird.Promise<T>;
}
}
type _Promise<T> = Promise<T>;