diff options
Diffstat (limited to 'lib/bridge/index.js')
| -rw-r--r-- | lib/bridge/index.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/bridge/index.js b/lib/bridge/index.js new file mode 100644 index 0000000..e0ab441 --- /dev/null +++ b/lib/bridge/index.js @@ -0,0 +1,25 @@ +import { execFile } from 'child_process' + +export default class Bridge { + constructor() { + this.cpus = [] + this.getCPUs() + } + getCPUs() { + this.run(['python/devices.py']).then( (stdout, stderr) => { + this.cpus = JSON.parse(stdout) + console.log(this.cpus) + }).catch( (err) => { + console.error('error fetching cpus:', err) + }) + } + run(args) { + return new Promise( (resolve, reject) => { + console.log('>', args.join(' ')) + execFile(process.env.PYTHON_BINARY, args, (err, stdout, stderr) => { + if (err) return reject(err) + return resolve(stdout, stderr) + }) + }) + } +}
\ No newline at end of file |
