summaryrefslogtreecommitdiff
path: root/app/relay/runner.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/relay/runner.js')
-rw-r--r--app/relay/runner.js40
1 files changed, 18 insertions, 22 deletions
diff --git a/app/relay/runner.js b/app/relay/runner.js
index 361fecc..06fa85e 100644
--- a/app/relay/runner.js
+++ b/app/relay/runner.js
@@ -121,31 +121,31 @@ export function build_params(module, activity, task) {
}
}
-export function run_system_command(cmd, cb) {
- console.log('running system command:', cmd.cmd)
- switch(cmd.cmd) {
+export function run_system_command(opt, cb) {
+ console.log('running system command:', opt.cmd)
+ switch(opt.cmd) {
case 'nvidia-smi':
case 'uptime':
case 'w':
- execFile(cmd.cmd, [], cb)
+ execFile(opt.cmd, [], cb)
break
case 'ps':
- execFile(cmd.cmd, ['au'], cb)
+ execFile('ps', ['au'], cb)
break
case 'df':
execFile('df', ['-h'], cb)
break
case 'ls':
- list_directory(cmd, cb)
+ list_directory(opt, cb)
break
case 'du':
- disk_usage(cmd, cb)
+ disk_usage(opt, cb)
break
case 'list_sequences':
- list_sequences(cmd, cb)
+ list_sequences(opt, cb)
break
case 'dir_to_video':
- dir_to_video(cmd, cb)
+ dir_to_video(opt, cb)
break
default:
cb({ error: 'no such command' })
@@ -161,8 +161,7 @@ export function module_dir(opt, dir){
if (!module) {
return null
}
- const dir = path.join(module.cwd, dir.replace(/\.\.?\//g, ''))
- return dir
+ return path.join(module.cwd, dir.replace(/\.\.?\//g, ''))
}
export function list_directory(opt, cb) {
@@ -194,6 +193,7 @@ export function list_directory(opt, cb) {
// list the contents of a directory of sequences
export function list_sequences(opt, cb) {
list_directory(opt, (files, root_dir) => {
+ // console.log(files, root_dir)
const sequencePromises = files.filter(d => !!d.dir).map(f => {
return list_sequence(opt, f, root_dir)
})
@@ -213,17 +213,14 @@ export function list_sequence(opt, f, root_dir) {
}
readdir(path.join(root_dir, f.name)).then(files => {
const middle_file = files[Math.floor(files.length/2)]
- const filePromises = []
- filePromises.push(stat_promise(path.join(root_dir, f.name, middle_file)))
- sequence.count = files.length
- return Promise.all(filePromises)
- }).then(stats => {
- if (stats.length) {
- sequence.frame = {
- prefix: middle_file.split('_')[0]
- size: stat.size,
- }
+ sequence.frame = {
+ prefix: middle_file.split('_')[0],
}
+ sequence.count = files.length
+ // console.log(sequence.count)
+ return stat_promise(path.join(root_dir, f.name, middle_file))
+ }).then(stat => {
+ sequence.frame.size = stat.size
resolve(sequence)
}).catch(err => reject(err))
})
@@ -244,7 +241,6 @@ export function dir_to_video(opt, db) {
// output: the path (in renders/) that contains the video
// run the dir to video script with CWD as the directory and first input as ../renders plus the directory name
// list the file in renders...
- cb([])
execFile('./bin/dir_to_video.pl', params, {
cwd: module.cwd,
}, cb)