[Swift-commit] r3553 - in usertools/swift/swiftconfig: bin lib/perl

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Tue Aug 17 23:27:04 CDT 2010


Author: davidk
Date: 2010-08-17 23:27:04 -0500 (Tue, 17 Aug 2010)
New Revision: 3553

Modified:
   usertools/swift/swiftconfig/bin/swiftconfig
   usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm
Log:
Various bug fixes and improvements


Modified: usertools/swift/swiftconfig/bin/swiftconfig
===================================================================
--- usertools/swift/swiftconfig/bin/swiftconfig	2010-08-18 00:50:11 UTC (rev 3552)
+++ usertools/swift/swiftconfig/bin/swiftconfig	2010-08-18 04:27:04 UTC (rev 3553)
@@ -19,7 +19,6 @@
 my $option_list         = q{};            # List information about config
 my $option_remove       = q{};            # Remove entry from sites.xml
 my $option_edit         = q{};            # Edit mode
-my $option_describe     = q{};            # Print raw XML configuration
 my $option_default      = q{};            # When adding a site, use all defaults
 my $option_template     = q{};            # Create config from template specified
 my $option_copy         = q{};            # Copy an existing configuration
@@ -29,7 +28,6 @@
 # Assign variables from command line options
 GetOptions(
     'remove=s'              => \$option_remove,
-    'describe=s'            => \$option_describe,
     'default|defaults'      => \$option_default,
     'full'                  => sub { $option_default = 0; },
     'template=s'            => \$option_template,
@@ -45,6 +43,18 @@
 my $xml = new XML::Simple();
 initialize_swiftconfig();
 
+# Check command line options
+if( !$option_remove 
+    && !$option_template 
+    && !$option_edit 
+    && !$option_copy 
+    && !$option_applications 
+    && !$option_import 
+    && !$option_list) {
+    print "Incorrect usage. See swiftconfig -help for more information\n";  
+    exit;
+}
+
 # Create all required directories
 my $dotswift_directory = "$ENV{'HOME'}/.swift";
 create_directory("$ENV{'HOME'}/.ssh");
@@ -225,24 +235,27 @@
        my $quit = 0;
        while($quit == 0) {
            print "\n(E)dit, (a)dd, (r)emove, (l)ist, or (q)uit: ";
-           my $edit_or_add = <STDIN>;
-           chomp($edit_or_add);
+           my $command = <STDIN>;
+           chomp($command);
            
-           if(lc($edit_or_add) eq 'a') {
+           if(lc($command) eq 'a') {
                add_application("$dotswift_directory/apps/$application_set.apps");
            }
-           elsif(lc($edit_or_add) eq 'q') {
+           elsif(lc($command) eq 'q') {
                $quit = 1;
            }
-           elsif(lc($edit_or_add) eq 'r') {
+           elsif(lc($command) eq 'r') {
                 remove_application("$dotswift_directory/apps/$application_set.apps");
            }
-           elsif(lc($edit_or_add) eq 'l') {
+           elsif(lc($command) eq 'l') {
                 list_applications("$dotswift_directory/apps/$application_set.apps");
            }
-           elsif(lc($edit_or_add) eq 'e') {
+           elsif(lc($command) eq 'e') {
                 edit_application("$dotswift_directory/apps/$application_set.apps");
            }
+           else {
+               print "Unknown option: $command\n";
+           }
      }
 }
 
@@ -256,19 +269,38 @@
     }
 }
 
+# List various about swiftconfig
 if($option_list) {
 
     if ($option_list eq "templates") {
         print_directory($template_directory);
     }
-    elsif ($option_list eq "configs") {
+    elsif ($option_list eq "configs" || $option_list eq "sites") {
         print_directory("$dotswift_directory/sites");
     }
     # Assume it's the name of a configuration
     else {
         my @matched_configs = glob("$dotswift_directory/sites/$option_list");
         foreach my $site (@matched_configs) {
-            system("cat $site/sites.xml");
+            if(-e "$site/sites.xml") {
+                print "sites.xml:\n";
+                system("cat $site/sites.xml");
+                print "\n";
+            }
+            else {
+                print "Unable to find configuration $option_list\n";
+            }
+            if(-e "$site/apps") {
+                open(APPFILE, "$site/apps") || die "Unable to open $site/apps";
+                my @appdata = <APPFILE>;
+                close(APPFILE);
+                print "Application sets: ";
+                foreach my $app(@appdata) {
+                    chomp($app);
+                    print "$app ";
+                }
+                print "\n\n";
+            }
         }
     }
 }

Modified: usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm
===================================================================
--- usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm	2010-08-18 00:50:11 UTC (rev 3552)
+++ usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm	2010-08-18 04:27:04 UTC (rev 3553)
@@ -504,10 +504,11 @@
                 foreach (@profiles) {
                     if( m/maxwalltime=\"(\d+:\d+:\d+)\"/ig ) {
                         $wallfound=1;
-                        $time = get_entry("Walltime", $1, 0);
+                        my $default_time = $1;
+                        $time = get_entry("Walltime", $default_time, 0);
                         while($time !~ m/(\d+:\d+:\d+)/ ) {
                             print "Error: incorrect format\n";
-                            $time = get_entry("Walltime", $1, 0);
+                            $time = get_entry("Walltime", $default_time, 0);
                         }
                         s/(\d+:\d+:\d+)/$time/g;
                     }
@@ -546,6 +547,7 @@
     }
 }
 
+# Associate application sets with a configuration
 sub update_site_applications {
     my ($site) = @_;
     my $apps = '';
@@ -591,6 +593,7 @@
     print "Successfully saved application sets for $site\n\n";
 }
 
+# Import existing XML file into swiftconfig style format
 sub import_xml {
     my ($xml_filename) = @_;
     if(! -e $xml_filename) {
@@ -621,6 +624,7 @@
     }
 }
 
+# Import tc.data files into swiftconfig application set
 sub import_tc {
     my ($tc_filename) = @_;
     if(! -e $tc_filename) {




More information about the Swift-commit mailing list