From 91cae4e0987b44313ebb091bb1cd376130c5a4be Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sun, 6 Jan 2008 07:05:55 +0000 Subject: condense check_job_dir() with a loop svn path=/branches/new-fu/; revision=331 --- client/scireclient.pl | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/client/scireclient.pl b/client/scireclient.pl index f630f7f..2415373 100755 --- a/client/scireclient.pl +++ b/client/scireclient.pl @@ -40,6 +40,7 @@ sub talk_to_server { return $exitcode; } else { # We'll need to add a call to setuid() here at some point + #ok folks so here's how this thang goes down. #1. Connect. $comm = Scire::Communicator->new( host => $conf{host}, user => $conf{user}, port => $conf{port} ); @@ -96,25 +97,13 @@ sub parse_command_line { } sub check_job_dir { - if (! -d $conf{job_dir}) { - print "WARNING! $conf{job_dir} does not exist...creating\n"; - mkpath( $conf{job_dir}, {verbose => 1, mode => 0660}) - or die("Couldn't make $conf{job_dir} w/ perms 0660: $!"); - } - if (! -d "$conf{job_dir}/queue") { - print "WARNING! $conf{job_dir}/queue does not exist...creating\n"; - mkpath( "$conf{job_dir}/queue", {verbose => 1, mode => 0660}) - or die("Couldn't make $conf{job_dir}/queue w/ perms 0660: $!"); - } - if (! -d "$conf{job_dir}/done") { - print "WARNING! $conf{job_dir}/done does not exist...creating\n"; - mkpath( "$conf{job_dir}/done", {verbose => 1, mode => 0660}) - or die("Couldn't make $conf{job_dir}/done w/ perms 0660: $!"); - } - if (! -d "$conf{job_dir}/failed") { - print "WARNING! $conf{job_dir}/failed does not exist...creating\n"; - mkpath( "$conf{job_dir}/failed", {verbose => 1, mode => 0660}) - or die("Couldn't make $conf{job_dir}/failed w/ perms 0660: $!"); + my @checkdirs = ($conf{job_dir}, "$conf{job_dir}/queue", "$conf{job_dir}/done", "$conf{job_dir}/failed"); + for my $dir (@checkdirs) { + if (! -d $dir) { + print "WARNING! ${dir} does not exist...creating\n"; + mkpath( $dir, {verbose => 1, mode => 0660}) + or die("Couldn't make ${dir} w/ perms 0660: $!"); + } } } -- cgit v1.2.3-65-gdbad