|
1 | | -// declare module "python-bridge" { |
2 | | - interface pythonBridge extends Function { |
3 | | - (options?: PythonBridgeOptions): PythonBridge; |
4 | | - } |
| 1 | +interface pythonBridge extends Function { |
| 2 | + (options?: PythonBridgeOptions): PythonBridge; |
| 3 | +} |
5 | 4 |
|
6 | | - export const pythonBridge: pythonBridge |
7 | 5 |
|
8 | | - export interface PythonBridgeOptions { |
9 | | - intepreter?: string; |
10 | | - stdio?: [PipeStdin, PipeStdout, PipeStderr]; |
11 | | - cwd?: string; |
12 | | - env?: { [key:string]: string; }; |
13 | | - uid?: number; |
14 | | - gid?: number; |
15 | | - } |
| 6 | +export const pythonBridge: pythonBridge |
16 | 7 |
|
17 | | - export interface PythonBridge { |
18 | | - (literals: TemplateStringsArray | string, ...placeholders: any[]): Promise<any>; |
19 | | - ex(literals: TemplateStringsArray | string, ...placeholders: any[]): Promise<void>; |
20 | | - lock<T>(withLock: (python: PythonBridge) => Promise<T>): Promise<T> |
21 | | - pid: number; |
22 | | - end(): Promise<void>; |
23 | | - disconnect(): Promise<void>; |
24 | | - kill(signal: string | number): void; |
25 | | - stdin: NodeJS.WritableStream; |
26 | | - stdout: NodeJS.ReadableStream; |
27 | | - stderr: NodeJS.ReadableStream; |
28 | | - connected: boolean; |
29 | | - } |
| 8 | +export interface PythonBridgeOptions { |
| 9 | + intepreter?: string; |
| 10 | + stdio?: [PipeStdin, PipeStdout, PipeStderr]; |
| 11 | + cwd?: string; |
| 12 | + env?: { [key:string]: string; }; |
| 13 | + uid?: number; |
| 14 | + gid?: number; |
| 15 | +} |
| 16 | + |
| 17 | +export interface PythonBridge { |
| 18 | + (literals: TemplateStringsArray | string, ...placeholders: any[]): Bluebird.Promise<any>; |
| 19 | + ex(literals: TemplateStringsArray | string, ...placeholders: any[]): Bluebird.Promise<void>; |
| 20 | + lock<T>(withLock: (python: PythonBridge) => Promise<T>): Bluebird.Promise<T> |
| 21 | + pid: number; |
| 22 | + end(): Promise<void>; |
| 23 | + disconnect(): Promise<void>; |
| 24 | + kill(signal: string | number): void; |
| 25 | + stdin: NodeJS.WritableStream; |
| 26 | + stdout: NodeJS.ReadableStream; |
| 27 | + stderr: NodeJS.ReadableStream; |
| 28 | + connected: boolean; |
| 29 | +} |
30 | 30 |
|
31 | | - export function isPythonException(name: string): (e: any) => boolean; |
32 | | - export function isPythonException(name: string, e: any): boolean; |
33 | | - |
34 | | - export class PythonException extends Error { |
35 | | - exception: { |
36 | | - message: string; |
37 | | - args: any[]; |
38 | | - type: { name: string; module: string; } |
39 | | - format: string[]; |
40 | | - }; |
41 | | - traceback: { |
42 | | - lineno: number; |
43 | | - strack: string[]; |
44 | | - format: string[] |
45 | | - }; |
| 31 | +export function isPythonException(name: string): (e: any) => boolean; |
| 32 | +export function isPythonException(name: string, e: any): boolean; |
| 33 | + |
| 34 | +export class PythonException extends Error { |
| 35 | + exception: { |
| 36 | + message: string; |
| 37 | + args: any[]; |
| 38 | + type: { name: string; module: string; } |
| 39 | + format: string[]; |
| 40 | + }; |
| 41 | + traceback: { |
| 42 | + lineno: number; |
| 43 | + strack: string[]; |
46 | 44 | format: string[] |
| 45 | + }; |
| 46 | + format: string[] |
| 47 | +} |
| 48 | + |
| 49 | +export type Pipe = "pipe" | "ignore" | "inherit"; |
| 50 | +export type PipeStdin = Pipe | NodeJS.ReadableStream; |
| 51 | +export type PipeStdout = Pipe | NodeJS.WritableStream; |
| 52 | +export type PipeStderr = Pipe | NodeJS.WritableStream; |
| 53 | + |
| 54 | +export namespace Bluebird { |
| 55 | + interface Promise<T> extends _Promise<T> { |
| 56 | + timeout(number): Bluebird.Promise<T>; |
47 | 57 | } |
| 58 | +} |
48 | 59 |
|
49 | | - export type Pipe = "pipe" | "ignore" | "inherit"; |
50 | | - export type PipeStdin = Pipe | NodeJS.ReadableStream; |
51 | | - export type PipeStdout = Pipe | NodeJS.WritableStream; |
52 | | - export type PipeStderr = Pipe | NodeJS.WritableStream; |
53 | | -// } |
| 60 | +type _Promise<T> = Promise<T>; |
0 commit comments