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

View of /Sprout/LoadScript.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Jun 9 19:06:55 2005 UTC (14 years, 6 months ago) by parrello
Branch: MAIN
*** empty log message ***

#!/usr/bin/perl -w

=head1 General-Purpose Load Script

This method executes a list of commands. If a command fails, it writes
the unprocessed commands into a file so they can be resumed.

The command takes one positional parameter.  The first
parameter must be one of the following.

=over 4

=item test

Executes a series of simple test commands to verify the operation
of this script.

=item seed

Loads the SEED database.

=back

The currently-supported command-line options are as follows.

=over 4

=item trace

Numeric trace level. A higher trace level causes more messages to appear. The
default trace level is 2.

=item skip

Number of commands to skip. This allows the user to resume an interrupted load.
The default is 0, indicating that the whole list will be executed.

=back

=cut

use strict;
use Tracer;
use FIG;
use Sprout;
use DocUtils;
use TestUtils;
use Cwd;
use File::Copy;
use File::Path;

# Get the command-line options.
my ($options, @parameters) = Tracer::ParseCommand({ trace => 2, skip => 0 }, @ARGV);
# Set up tracing.
my $traceLevel = $options->{trace};
TSetup("$traceLevel errors Tracer DocUtils COMMANDS", "+>$FIG_Config::temp/trace.log");

# Get the command and convert it to lower case.
my ($command) = @parameters;
$command = lc $command;
# Create the command list.
my @commandList;
if ($command eq 'seed') {
    @commandList = FIG::load_all_list();
} elsif ($command eq 'test') {
    for (my $i = 1; $i < 10; $i++) {
        push @commandList, "TestScript line$i";
    }
} else {
    Confess("Invalid command $command.");
}
# Execute the commands.
my $n = $#commandList;
for (my $i = $options->{skip}; $i <= $n; $i++) {
    my $command = $commandList[$i];
    Trace("Running $command ($i of $n).") if T(COMMANDS => 0);
    system($command);
}
Trace("Load complete") if T(0);

1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3