|
From: Jeff S. <jsq...@us...> - 2002-05-18 21:49:06
|
Update of /cvsroot/env-switcher/env-switcher/src
In directory usw-pr-cvs1:/tmp/cvs-serv3721/src
Modified Files:
switcher.in switcher.tcl.in
Log Message:
- Eliminate $switcher_version -- not used anymore
- Added functionality for "announce" attribute for env-switcher bug #547637
- Do not print warnings if we can't find a modulefile for a name on a
default attribute; this causes "module load switcher" to fail, and doesn't
give any indication of why. The "announce" functionality will give us
that instead.
- Added diag() subroutine and --diag command line arg, but still
non-functional for the moment. May be redundant after fully implementing
--announce; we'll see
Index: switcher.in
===================================================================
RCS file: /cvsroot/env-switcher/env-switcher/src/switcher.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** switcher.in 23 Apr 2002 06:22:55 -0000 1.1
--- switcher.in 18 May 2002 21:49:03 -0000 1.2
***************
*** 12,16 ****
#
- $switcher_version = "1.0";
$prefix = "@prefix@";
$system_filename = "@sysconfdir@/switcher.ini";
--- 12,15 ----
***************
*** 845,856 ****
############################################################################
#
! # show_exec
#
! # Take all the tags, resolve all the attributes, and come up with a
! # list of module commands to execute that will setup the environment.
#
############################################################################
! sub show_exec {
my %attributes;
my $d, $a;
--- 844,858 ----
############################################################################
#
! # examine_tags
#
! # Look at all tags, resolve all the attributes, and either output the
! # list of module commands to execute that will setup the environment,
! # or display an announcement message for each.
#
############################################################################
! sub examine_tags {
! my ($want_default, $want_announce) = @_;
!
my %attributes;
my $d, $a;
***************
*** 870,874 ****
# Select all the attributes for this tag and sort them
! %attributes = resolve_tag($system, $user);
# Extract the default and announce attributes
--- 872,876 ----
# Select all the attributes for this tag and sort them
! %attributes = resolve_tag(0, 0);
# Extract the default and announce attributes
***************
*** 877,887 ****
$a = $attributes{$announce_attribute};
! if ($d ne "" && $d ne "none") {
if (-f "$tag_dir/$tag/$d") {
print "$tag/$d\n";
} else {
! print_warning("Warning: unable to find modulefile for " .
! "tag \"$tag\", name \"$d\"\n" .
! "Warning: tag \"$tag\" will be skipped\n");
}
}
--- 879,899 ----
$a = $attributes{$announce_attribute};
! # List the default tags
!
! if ($want_default == 1 && $d ne "" && $d ne "none") {
if (-f "$tag_dir/$tag/$d") {
print "$tag/$d\n";
+ }
+ }
+
+ # Print announcement notices
+
+ if ($want_announce == 1 &&
+ ($a =~ /true/i || $a eq "1")) {
+ if (-f "$tag_dir/$tag/$d") {
+ print "echo switcher: Loading $tag:$d;\n";
} else {
! print "echo switcher: Unable to find modulefile for $tag:$d " .
! "-- skipping;\n";
}
}
***************
*** 895,898 ****
--- 907,956 ----
############################################################################
#
+ # show_exec
+ #
+ # Take all the tags, resolve all the attributes, and come up with a
+ # list of module commands to execute that will setup the environment.
+ #
+ ############################################################################
+
+ sub show_exec {
+ return examine_tags(1, 0);
+ }
+
+ ############################################################################
+ #
+ # announce
+ #
+ # Take all the tags, resolve all the attributes, and display an
+ # announcement message for each.
+ #
+ ############################################################################
+
+ sub announce {
+ return examine_tags(0, 1);
+ }
+
+ ############################################################################
+ #
+ # diag
+ #
+ # Do some comparisons between the user's $HOME/.switcher.ini and the
+ # system switcher.ini and report on the following conditions:
+ #
+ # - If the user's $HOME/.switcher.ini has a tag that does not exist
+ # - If the user's $HOME/.switcher.ini has a value for the "default"
+ # attribute that is a name that does not exist
+ # - If the system switcher.ini has a tag that does not exist
+ # - If the system switcher.ini has a value for the "default" attribute
+ # that is a name that does not exist
+ #
+ ############################################################################
+
+ sub diag {
+ 0;
+ }
+
+ ############################################################################
+ #
# write_ini_file
#
***************
*** 1028,1034 ****
}
! # The --list and --show-exec commands are special. If no tag is
! # given, it's an implcit "--list". If a tag is given with nothing
! # else, it's an implicit "<tag> --list".
$tag = $ARGV[0];
--- 1086,1091 ----
}
! # A few commands are special -- they don't taken an initial <tag>
! # argument.
$tag = $ARGV[0];
***************
*** 1040,1043 ****
--- 1097,1106 ----
} elsif ($ARGV[0] eq "--show-exec") {
show_exec();
+ $action_done = 1;
+ } elsif ($ARGV[0] eq "--diag") {
+ diag();
+ $action_done = 1;
+ } elsif ($ARGV[0] eq "--announce") {
+ announce();
$action_done = 1;
} else {
Index: switcher.tcl.in
===================================================================
RCS file: /cvsroot/env-switcher/env-switcher/src/switcher.tcl.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** switcher.tcl.in 16 May 2002 14:01:14 -0000 1.2
--- switcher.tcl.in 18 May 2002 21:49:03 -0000 1.3
***************
*** 35,38 ****
--- 35,49 ----
module use @SWITCHER_DATADIR@
+ # If we're not removing the module, call switcher to announce what
+ # modules we're loading (per user/system settings, of course)
+
+ set is_module_rm [module-info mode remove]
+ if { ! $is_module_rm } {
+ set announce_output [exec switcher --announce]
+ if { $announce_output != ""} {
+ puts "$announce_output;"
+ }
+ }
+
# Now invoke the switcher perl script to get a list of the modules
# that need to be loaded. If we get a non-empty string back, load
|