@robot-resources/cli-core 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/python-bridge.mjs +29 -4
package/package.json
CHANGED
package/python-bridge.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process';
|
|
1
|
+
import { execSync, spawn } from 'node:child_process';
|
|
2
2
|
import { existsSync, mkdirSync } from 'node:fs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
@@ -88,14 +88,39 @@ export function ensureVenv(pythonBin) {
|
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Install (or upgrade) the router Python package into the managed venv.
|
|
91
|
+
* Prints progress every 5 seconds to keep terminal sessions alive
|
|
92
|
+
* (OC session handlers reap silent processes).
|
|
91
93
|
*
|
|
92
94
|
* @param {object} [options]
|
|
93
|
-
* @param {'pipe'|'inherit'} [options.stdio='pipe'] — controls install output visibility
|
|
94
95
|
* @param {number} [options.timeout=120000] — pip install timeout in ms
|
|
95
96
|
*/
|
|
96
|
-
export function installRouter({
|
|
97
|
+
export function installRouter({ timeout = 120_000 } = {}) {
|
|
97
98
|
const pip = getVenvPip();
|
|
98
|
-
|
|
99
|
+
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
const proc = spawn(pip, ['install', '--upgrade', ROUTER_PACKAGE], {
|
|
102
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
103
|
+
timeout,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
process.stdout.write(' Installing dependencies...\n');
|
|
107
|
+
let seconds = 0;
|
|
108
|
+
const progress = setInterval(() => {
|
|
109
|
+
seconds += 4;
|
|
110
|
+
process.stdout.write(` Installing dependencies... ${seconds}s\n`);
|
|
111
|
+
}, 4000);
|
|
112
|
+
|
|
113
|
+
proc.on('close', (code) => {
|
|
114
|
+
clearInterval(progress);
|
|
115
|
+
if (code === 0) resolve();
|
|
116
|
+
else reject(new Error(`pip install exited with code ${code}`));
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
proc.on('error', (err) => {
|
|
120
|
+
clearInterval(progress);
|
|
121
|
+
reject(err);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
99
124
|
}
|
|
100
125
|
|
|
101
126
|
/**
|