IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 20, 2008, 9:37:44 AM (18 years ago)
Author:
bills
Message:

allow multiple request files per fileset, add --dbname option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstamp_queue_requests.pl

    r17893 r18234  
    22#
    33# pstamp_queue_reqests.pl
     4#
    45# Query registered data stores for new postage stamp requests and add them to
    56# the database of pending requests.
    67#
    78
    8 # XXX TODO: need to take dbname as a paramter
    9 
    109use warnings;
    1110use strict;
    1211
    13 my $verbosity = 0;
     12use Getopt::Long qw( GetOptions );
    1413
    1514use Sys::Hostname;
    1615my $host = hostname();
    1716
    18 if ($verbosity) {
     17my $verbose;
     18my $dbname;
     19
     20GetOptions(
     21    'verbose'       =>  \$verbose,
     22    'dbname=s'      =>  \$dbname,
     23);
     24
     25if ($verbose) {
    1926    print STDERR "\n\n";
    2027    print STDERR "Starting script $0 on $host\n\n";
     
    5663{
    5764    my $command = "$pstamptool -datastore";
     65    $command .= " -dbname $dbname" if $dbname;
     66
    5867    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    59         run(command => $command, verbose => $verbosity);
     68        run(command => $command, verbose => $verbose);
    6069    unless ($success) {
    61         die("Unable to perform pstamptool -datastore: $error_code >> 8");
     70        my $rc = $error_code >> 8;
     71        die("Unable to perform pstamptool -datastore: $rc");
    6272    }
    6373
     
    96106        $command .= " --last_fileset $ds->{lastFileset}" if $ds->{lastFileset};
    97107        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    98             run(command => $command, verbose => $verbosity);
     108            run(command => $command, verbose => $verbose);
    99109        unless ($success) {
    100110            die("Unable to perform $command: $error_code");
     
    115125    # each line contains a fileset
    116126    #
     127    # XXX: we probably should set a limit on the number of these we process
     128    # otherwise this could take a long time and the task could time out
    117129    foreach my $line (@lines) {
    118130        # parse the line into fields split by whitespace
     
    125137            my $command = "$dsfilesetls --uri $uri";
    126138            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    127                     run(command => $command, verbose => $verbosity);
     139                    run(command => $command, verbose => $verbose);
    128140            unless ($success) {
    129141                die("Unable to perform $command: $error_code");
     
    148160            {
    149161                my $command = "$pstamptool -addreq -uri $req_uri -ds_id $ds_id -out_fileset $outProduct/$fs_name";
     162                $command .= " -dbname $dbname" if $dbname;
    150163                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    151                         run(command => $command, verbose => $verbosity);
     164                        run(command => $command, verbose => $verbose);
    152165                    unless ($success) {
    153                             # XXX: what do we do now?
    154                             die("Unable to perform $command: $error_code");
     166                        # XXX: what do we do now?
     167                        die("Unable to perform $command: $error_code");
    155168                    }
    156169            }
    157170            $lastFileset = $fs_name;
    158             # we only allow one request file per fileset
    159             # XXX TODO: maybe Relax this restriction
    160             last;
    161171        }
    162172    }
    163173
    164     ## now update the data store table with the last_fileset
     174    ## now update the last_fileset column in pstampDataStore
     175    ## XXX: we should probably do this before we process the fileset. Otherwise
     176    ## if we get an error from pstamptool we'll get stuck processing it over and over.
    165177    if ($lastFileset) {
    166178        # print "last fileset: $lastFileset\n";
    167179        {
    168180        my $command = "$pstamptool -ds_id $ds_id -moddatastore -last_fileset $lastFileset";
     181        $command .= " -dbname $dbname" if $dbname;
    169182        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    170             run(command => $command, verbose => $verbosity);
     183            run(command => $command, verbose => $verbose);
    171184            unless ($success) {
    172185                die("Unable to perform pstamptool -moddatastore: $error_code");
Note: See TracChangeset for help on using the changeset viewer.