diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-06-30 14:22:25 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-06-30 14:22:25 +0000 |
commit | c397aab53496fa6508b6ca795486fe93b281e468 (patch) | |
tree | fbd23da9226d914b6e3778be3199f05cc3209b77 /vest | |
parent | 8303ad36d0a94059c8674131f4760e2c1aac13bc (diff) |
par w/o -e dir
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@77 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'vest')
-rwxr-xr-x | vest/parallelize.pl | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/vest/parallelize.pl b/vest/parallelize.pl index d89dcd33..cd2576a9 100755 --- a/vest/parallelize.pl +++ b/vest/parallelize.pl @@ -23,7 +23,7 @@ use Cwd qw(getcwd); my $recycle_clients; # spawn new clients when previous ones terminate my $stay_alive; # dont let server die when having zero clients my $joblist = ""; -my $errordir; +my $errordir=""; my $multiline; my @files_to_stage; my $verbose = 1; @@ -71,6 +71,32 @@ sub preview_files { debug($cmd,$text); $text } +sub prefix_dirname($) { + #like `dirname but if ends in / then return the whole thing + local ($_)=@_; + if (/\/$/) { + $_; + } else { + s#/[^/]$##; + $_ ? $_ : ''; + } +} +sub extend_path($$;$$) { + my ($base,$ext,$mkdir,$baseisdir)=@_; + if (-d $base) { + $base.="/"; + } else { + my $dir; + if ($baseisdir) { + $dir=$base; + $base.='/' unless $base =~ /\/$/; + } else { + $dir=prefix_dirname($base); + } + system("mkdir -p '$dir'") if $mkdir; + } + return $base.$ext; +} my $abscwd=abspath(&getcwd); sub print_help; @@ -110,10 +136,6 @@ for my $arg (@ARGV) { die "Please specify a command to parallelize\n" if $cmd eq ''; -if ($errordir){ - `mkdir -p $errordir`; -} - if ($verbose){ print STDERR "Parallelizing: $cmd\n\n"; } # set cleanup handler @@ -225,7 +247,7 @@ sub numof_live_jobs { return ($#livejobs + 1); } my (@errors,@outs,@cmds); -my $scriptfile="$errordir/$executable.sh"; +my $scriptfile=extend_path("$errordir/","$executable.sh",1,1); if ($errordir) { open SF,">",$scriptfile || die; print SF $cmd,"\n"; |