mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-14 07:16:04 +08:00
Add: Web app 0.2.1
This commit is contained in:
28
webapp/packages/main/src/pyshell.ts
Normal file
28
webapp/packages/main/src/pyshell.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import {alasPath, pythonPath} from '/@/config';
|
||||
|
||||
const {PythonShell} = require('python-shell');
|
||||
const treeKill = require('tree-kill');
|
||||
|
||||
|
||||
export class PyShell extends PythonShell {
|
||||
constructor(script: string, args: Array<string> = []) {
|
||||
const options = {
|
||||
mode: 'text',
|
||||
args: args,
|
||||
pythonPath: pythonPath,
|
||||
scriptPath: alasPath,
|
||||
};
|
||||
super(script, options);
|
||||
}
|
||||
|
||||
on(event: string, listener: (...args: any[]) => void): this {
|
||||
this.removeAllListeners(event);
|
||||
super.on(event, listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
kill(): this {
|
||||
treeKill(this.childProcess.pid, 'SIGTERM');
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user