[Swift-commit] r7340 - trunk/bin

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Wed Nov 27 08:38:38 CST 2013


Author: davidk
Date: 2013-11-27 08:38:37 -0600 (Wed, 27 Nov 2013)
New Revision: 7340

Modified:
   trunk/bin/swift
   trunk/bin/swiftrun
Log:
Better error handling for invalid site names


Modified: trunk/bin/swift
===================================================================
--- trunk/bin/swift	2013-11-26 22:59:16 UTC (rev 7339)
+++ trunk/bin/swift	2013-11-27 14:38:37 UTC (rev 7340)
@@ -155,10 +155,11 @@
    CMDLINE="$( swiftrun $CMDLINE )"
    for cmd in $CMDLINE
    do
-      if [[ "$cmd" == *-Dscript.dir* ]];
-      then
+      if [[ "$cmd" == *-Dscript.dir* ]]; then
          OPTIONS="$OPTIONS $cmd"
          CMDLINE=$( echo $CMDLINE | sed s@$cmd@@g )
+      elif [[ "$cmd" == *--SWIFTRUNQUIT* ]]; then
+         exit 1
       fi
    done
 fi

Modified: trunk/bin/swiftrun
===================================================================
--- trunk/bin/swiftrun	2013-11-26 22:59:16 UTC (rev 7339)
+++ trunk/bin/swiftrun	2013-11-27 14:38:37 UTC (rev 7340)
@@ -5,6 +5,7 @@
 use FindBin qw($Bin);
 use lib "$FindBin::Bin/../lib/perl";
 use File::Basename;
+use File::Path;
 use Getopt::Long qw(GetOptionsFromArray);
 use Cwd;
 
@@ -132,6 +133,17 @@
    push( @new_swift_args, "-config $run_directory/$property_filename" );
 }
 
+sub site_is_defined {
+   my $site = $_[0];
+   my $isDefined=0;
+   while( my( $key, $value ) = each( %properties ) ) {
+     if( $key =~ m/^site\.$site/i ) {
+        $isDefined=1;
+      }
+   }
+   return $isDefined;
+}
+
 # Write sites.xml to disk
 sub write_sites {
    my $filename = $_[0];
@@ -144,6 +156,12 @@
    } 
 
    foreach my $site(@sites) {
+      if( ! &site_is_defined($site) ) {
+         print STDERR "Site $site is not defined\n";
+         print " --SWIFTRUNQUIT "; 
+         rmtree $run_directory || die "Failed to remove $run_directory: $!\n";
+         exit 1;
+      }
       print SITES &create_pool_entry($site);
    }
 




More information about the Swift-commit mailing list