summaryrefslogtreecommitdiff
path: root/vest
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-30 14:22:25 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-30 14:22:25 +0000
commit908abbbea0c491de061f43b246581e0cf4f3f02e (patch)
tree17dd6f90c1006b060d7822efe8c8fa131247a25e /vest
parenta38a6728827aae6b1f98dc8d441d10642a1fe01a (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-xvest/parallelize.pl34
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";