diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-06-30 20:17:24 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-06-30 20:17:24 +0200 |
| commit | 7c5ca9fdcafcec0e3781ed856eba42cd608f0e15 (patch) | |
| tree | a4425e8ce03538c1741e6c10b0a2459bcb03aea2 /lib/bridge/index.js | |
| parent | 82cf40b516b5ab11c34b3642a01603ec1b590c9f (diff) | |
es6 stuff
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 |
