[Bio] / Sprout / LoadScript.pl Repository:
ViewVC logotype

Diff of /Sprout/LoadScript.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Thu Jun 9 19:06:55 2005 UTC revision 1.4, Tue Feb 5 21:55:27 2008 UTC
# Line 2  Line 2 
2    
3  =head1 General-Purpose Load Script  =head1 General-Purpose Load Script
4    
5    C<LoadScript> [I<options>] I<command> [ I<trace1> I<trace2> ... I<traceN> ]
6    
7  This method executes a list of commands. If a command fails, it writes  This method executes a list of commands. If a command fails, it writes
8  the unprocessed commands into a file so they can be resumed.  the unprocessed commands into a file so they can be resumed.
9    
10  The command takes one positional parameter.  The first  The command takes multiple positional parameters.  The first
11  parameter must be one of the following.  parameter must be one of the following.
12    
13  =over 4  =over 4
# Line 21  Line 23 
23    
24  =back  =back
25    
26  The currently-supported command-line options are as follows.  The remaining positional parameters are added to the list of trace modules. So,
27    for example, the following command
28    
29        LoadScript seed FIG Stats
30    
31    would run the SEED load with tracing on for the B<FIG> and B<Stats> modules.
32    
33    In addition to the positional parameters, the following command-line options are
34    supported.
35    
36  =over 4  =over 4
37    
38  =item trace  =item trace
39    
40  Numeric trace level. A higher trace level causes more messages to appear. The  Numeric trace level. A higher trace level causes more messages to appear. The
41  default trace level is 2.  default trace level is C<2>.
42    
43  =item skip  =item skip
44    
45  Number of commands to skip. This allows the user to resume an interrupted load.  Number of commands to skip. This allows the user to resume an interrupted load.
46  The default is 0, indicating that the whole list will be executed.  The default is C<0>, indicating that the whole list will be executed.
47    
48    =item list
49    
50    TRUE if the commands should simply be listed, else FALSE. The default is FALSE (C<0>).
51    
52  =back  =back
53    
# Line 43  Line 57 
57  use Tracer;  use Tracer;
58  use FIG;  use FIG;
59  use Sprout;  use Sprout;
 use DocUtils;  
 use TestUtils;  
60  use Cwd;  use Cwd;
61  use File::Copy;  use File::Copy;
62  use File::Path;  use File::Path;
63    
64  # Get the command-line options.  # Get the command-line options.
65  my ($options, @parameters) = Tracer::ParseCommand({ trace => 2, skip => 0 }, @ARGV);  my ($options, @parameters) = Tracer::ParseCommand({ trace => 2, skip => 0, list => 0 }, @ARGV);
66    # Get the command and convert it to lower case.
67    my $command = lc shift @parameters;
68  # Set up tracing.  # Set up tracing.
69  my $traceLevel = $options->{trace};  my $traceLevel = $options->{trace};
70  TSetup("$traceLevel errors Tracer DocUtils COMMANDS", "+>$FIG_Config::temp/trace.log");  my $traceString = join(" ", $traceLevel, "errors", "Tracer", "COMMANDS", @parameters);
71    TSetup("$traceString", "+>$FIG_Config::temp/trace.log");
72  # Get the command and convert it to lower case.  # Insure the other FIG applications use the same trace setting.
73  my ($command) = @parameters;  $ENV{Trace} = $traceString;
74  $command = lc $command;  $ENV{TraceType} = "+>>$FIG_Config::temp/trace.log";
75  # Create the command list.  # Create the command list.
76  my @commandList;  my @commandList;
77  if ($command eq 'seed') {  if ($command eq 'seed') {
78        # Get the list of commands for doing a full load.
79      @commandList = FIG::load_all_list();      @commandList = FIG::load_all_list();
80        # Add the command to initialize the database.
81        unshift @commandList, "init_FIG";
82  } elsif ($command eq 'test') {  } elsif ($command eq 'test') {
83      for (my $i = 1; $i < 10; $i++) {      for (my $i = 1; $i < 10; $i++) {
84          push @commandList, "TestScript line$i";          push @commandList, "TestScript line$i";
# Line 69  Line 86 
86  } else {  } else {
87      Confess("Invalid command $command.");      Confess("Invalid command $command.");
88  }  }
89    # Set up the trace.
90    my $action = ($options->{list} ? "Showing" : "Running");
91  # Execute the commands.  # Execute the commands.
92  my $n = $#commandList;  my $n = @commandList;
93  for (my $i = $options->{skip}; $i <= $n; $i++) {  for (my $i = $options->{skip}; $i < $n; $i++) {
94      my $command = $commandList[$i];      my $command = $commandList[$i];
95      Trace("Running $command ($i of $n).") if T(COMMANDS => 0);      my $counter = $i + 1;
96        Trace(">> $action ($counter) of $n: $command.") if T(COMMANDS => 0);
97        if (! $options->{list}) {
98      system($command);      system($command);
99  }  }
100    }
101  Trace("Load complete") if T(0);  Trace("Load complete") if T(0);
102    
103  1;  1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3