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

Annotation of /Sprout/LoadScript.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 General-Purpose Load Script
4 :    
5 :     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.
7 :    
8 :     The command takes one positional parameter. The first
9 :     parameter must be one of the following.
10 :    
11 :     =over 4
12 :    
13 :     =item test
14 :    
15 :     Executes a series of simple test commands to verify the operation
16 :     of this script.
17 :    
18 :     =item seed
19 :    
20 :     Loads the SEED database.
21 :    
22 :     =back
23 :    
24 :     The currently-supported command-line options are as follows.
25 :    
26 :     =over 4
27 :    
28 :     =item trace
29 :    
30 :     Numeric trace level. A higher trace level causes more messages to appear. The
31 :     default trace level is 2.
32 :    
33 :     =item skip
34 :    
35 :     Number of commands to skip. This allows the user to resume an interrupted load.
36 :     The default is 0, indicating that the whole list will be executed.
37 :    
38 :     =back
39 :    
40 :     =cut
41 :    
42 :     use strict;
43 :     use Tracer;
44 :     use FIG;
45 :     use Sprout;
46 :     use DocUtils;
47 :     use TestUtils;
48 :     use Cwd;
49 :     use File::Copy;
50 :     use File::Path;
51 :    
52 :     # Get the command-line options.
53 :     my ($options, @parameters) = Tracer::ParseCommand({ trace => 2, skip => 0 }, @ARGV);
54 :     # Set up tracing.
55 :     my $traceLevel = $options->{trace};
56 :     TSetup("$traceLevel errors Tracer DocUtils COMMANDS", "+>$FIG_Config::temp/trace.log");
57 :    
58 :     # Get the command and convert it to lower case.
59 :     my ($command) = @parameters;
60 :     $command = lc $command;
61 :     # Create the command list.
62 :     my @commandList;
63 :     if ($command eq 'seed') {
64 :     @commandList = FIG::load_all_list();
65 :     } elsif ($command eq 'test') {
66 :     for (my $i = 1; $i < 10; $i++) {
67 :     push @commandList, "TestScript line$i";
68 :     }
69 :     } else {
70 :     Confess("Invalid command $command.");
71 :     }
72 :     # Execute the commands.
73 :     my $n = $#commandList;
74 :     for (my $i = $options->{skip}; $i <= $n; $i++) {
75 :     my $command = $commandList[$i];
76 :     Trace("Running $command ($i of $n).") if T(COMMANDS => 0);
77 :     system($command);
78 :     }
79 :     Trace("Load complete") if T(0);
80 :    
81 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3