[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.2, Wed Jul 27 20:04:33 2005 UTC
# Line 5  Line 5 
5  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
6  the unprocessed commands into a file so they can be resumed.  the unprocessed commands into a file so they can be resumed.
7    
8  The command takes one positional parameter.  The first  The command takes multiple positional parameters.  The first
9  parameter must be one of the following.  parameter must be one of the following.
10    
11  =over 4  =over 4
# Line 21  Line 21 
21    
22  =back  =back
23    
24  The currently-supported command-line options are as follows.  The remaining positional parameters are added to the list of trace modules. So,
25    for example, the following command
26    
27        LoadScript seed FIG Stats
28    
29    would run the SEED load
30    addition to the positional parameters, the following command-line options are
31    supported.
32    
33  =over 4  =over 4
34    
35  =item trace  =item trace
36    
37  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
38  default trace level is 2.  default trace level is C<2>.
39    
40  =item skip  =item skip
41    
42  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.
43  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.
44    
45    =item list
46    
47    TRUE if the commands should simply be listed, else FALSE. The default is FALSE (C<0>).
48    
49  =back  =back
50    
# Line 50  Line 61 
61  use File::Path;  use File::Path;
62    
63  # Get the command-line options.  # Get the command-line options.
64  my ($options, @parameters) = Tracer::ParseCommand({ trace => 2, skip => 0 }, @ARGV);  my ($options, @parameters) = Tracer::ParseCommand({ trace => 2, skip => 0, list => 0 }, @ARGV);
65    # Get the command and convert it to lower case.
66    my $command = lc shift @parameters;
67  # Set up tracing.  # Set up tracing.
68  my $traceLevel = $options->{trace};  my $traceLevel = $options->{trace};
69  TSetup("$traceLevel errors Tracer DocUtils COMMANDS", "+>$FIG_Config::temp/trace.log");  my $traceString = join(" ", $traceLevel, "errors", "Tracer", "COMMANDS", @parameters);
70    TSetup("$traceString", "+>$FIG_Config::temp/trace.log");
71  # Get the command and convert it to lower case.  # Insure the other FIG applications use the same trace setting.
72  my ($command) = @parameters;  $ENV{Trace} = $traceString;
73  $command = lc $command;  $ENV{TraceType} = "+>>$FIG_Config::temp/trace.log";
74  # Create the command list.  # Create the command list.
75  my @commandList;  my @commandList;
76  if ($command eq 'seed') {  if ($command eq 'seed') {
77        # Get the list of commands for doing a full load.
78      @commandList = FIG::load_all_list();      @commandList = FIG::load_all_list();
79        # Add the command to initialize the database.
80        unshift @commandList, "init_FIG";
81  } elsif ($command eq 'test') {  } elsif ($command eq 'test') {
82      for (my $i = 1; $i < 10; $i++) {      for (my $i = 1; $i < 10; $i++) {
83          push @commandList, "TestScript line$i";          push @commandList, "TestScript line$i";
# Line 69  Line 85 
85  } else {  } else {
86      Confess("Invalid command $command.");      Confess("Invalid command $command.");
87  }  }
88    # Set up the trace.
89    my $action = ($options->{list} ? "Showing" : "Running");
90  # Execute the commands.  # Execute the commands.
91  my $n = $#commandList;  my $n = @commandList;
92  for (my $i = $options->{skip}; $i <= $n; $i++) {  for (my $i = $options->{skip}; $i < $n; $i++) {
93      my $command = $commandList[$i];      my $command = $commandList[$i];
94      Trace("Running $command ($i of $n).") if T(COMMANDS => 0);      my $counter = $i + 1;
95        Trace(">> $action ($counter) of $n: $command.") if T(COMMANDS => 0);
96        if (! $options->{list}) {
97      system($command);      system($command);
98  }  }
99    }
100  Trace("Load complete") if T(0);  Trace("Load complete") if T(0);
101    
102  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3