IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28230


Ignore:
Timestamp:
Jun 4, 2010, 3:24:44 PM (16 years ago)
Author:
bills
Message:

Merging postage stamp script changes from the trunk into the production branch

Location:
tags/ipp-20100602/pstamp/scripts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20100602/pstamp/scripts/pstamp_finish.pl

    r28046 r28230  
    7676if ($product eq "NULL") {
    7777    # nothing more to do
    78     stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR);
     78    my_die("product is NULL!", $req_id, $PS_EXIT_PROG_ERROR);
    7979}
    8080
     
    9292
    9393        if (!mkdir $outdir) {
    94             print STDERR "cannot create output directory $outdir";
    95             stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
     94            my_die("cannot create output directory $outdir",$req_id, $PS_EXIT_UNKNOWN_ERROR);
    9695        }
    9796
    9897
    9998    } elsif (! -d $outdir ) {
    100         # XXX TODO: fault the request so we pstamp_finish doesn't keep trying to process the
    101         # request
    102         print STDERR "output directory $outdir exists but is not a directory";
    103         stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
     99        my_die("output directory $outdir exists but is not a directory", $req_id, $PS_EXIT_UNKNOWN_ERROR);
    104100    }
    105101
    106102    if (! -e $req_file ) {
    107         print STDERR "request file $req_file is missing\n";
    108         stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
     103        my_die("request file $req_file is missing", $req_id, $PS_EXIT_CONFIG_ERROR);
    109104    }
    110105
     
    115110        # Since a request got queued, the request file must have been readable at some
    116111        # point
    117         print STDERR "failed to read request_file $req_file" ;
    118         stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
     112        my_die("failed to read request file $req_file", $req_id, $PS_EXIT_CONFIG_ERROR);
    119113    }
    120114
     
    151145        my $output = join "", @$stdout_buf;
    152146        if (!$output) {
    153             if ($verbose) {
    154                 print STDERR "Request $req_id produced no jobs.\n"
    155             }
    156147            # This should not happen. A fake job should have been entered
    157             stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR);
     148            my_die("Request $req_id produced no jobs", $req_id, $PS_EXIT_PROG_ERROR);
    158149        } else {
    159 if (0) {
    160             my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc");
    161 
    162             my $jobs = parse_md_list($metadata);
    163 }
    164150            my $jobs = parse_md_fast($mdcParser, $output);
    165151
     
    181167            # this request had a duplicate request name yet the parser didn't give
    182168            # it an "ERROR style name.
    183             stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR);
     169            my_die("duplicate request not given a request name", $req_id, $PS_EXIT_PROG_ERROR);
    184170        }
    185171        my ($row, $req_info, $project) = get_request_info($rows, $rownum);
     
    187173        my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver);
    188174        my $image_db = $proj_hash->{dbname};
    189         if (!$image_db) {
    190             carp("failed to find imagedb for project: $project");
    191             if (!$fault) {
    192                 stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
    193             }
     175        if (!$image_db and !$fault) {
     176            # if project isn't resolvable, the paser should have faulted this job
     177            my_die("failed to find imagedb for project $project", $req_id, $PS_EXIT_CONFIG_ERROR);
    194178        }
    195179
     
    273257                run(command => $command, verbose => $verbose);
    274258            unless ($success) {
    275                 print STDERR "Unable to perform $command error code: $error_code\n";
    276259                $request_fault = $error_code >> 8;
     260                my_die("Unable to perform $command error code: $error_code", $req_id, $request_fault);
    277261            }
    278262        }
     
    282266        my $command = "$dsreg --list $reglist_name --add $fileset --product $product --type PSRESULTS";
    283267        $command .= " --link --datapath $outdir --ps0 $req_id";
    284 # XXX: let dsreg and config handle resolving dbname and dbserver
    285 #        $command .= " --dbname $dbname" if $dbname;
    286268
    287269        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    288270            run(command => $command, verbose => $verbose);
    289271        unless ($success) {
    290             #die("Unable to perform $command error code: $error_code");
    291             print STDERR "Unable to perform $command error code: $error_code\n";
    292272            $request_fault = $error_code >> 8;
    293             # fall through to stop the request
     273            my_die("Unable to perform $command error code: $error_code\n", $req_id, $request_fault);
    294274        }
    295275    }
    296276    # set the request's state to stop
    297277    {
    298         my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop -set_fault $request_fault";
     278        my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop";
    299279        $command   .= " -dbname $dbname" if $dbname;
    300280        $command   .= " -dbserver $dbserver" if $dbserver;
     
    308288}
    309289
    310 sub stop_request_and_exit {
     290sub my_die {
     291    my $msg = shift;
    311292    my $req_id = shift;
    312293    my $fault  = shift;
    313294
    314     my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop -set_fault $fault";
     295    carp($msg);
     296
     297    my $command = "$pstamptool -updatereq -req_id $req_id -set_fault $fault";
    315298    $command   .= " -dbname $dbname" if $dbname;
    316299    $command   .= " -dbserver $dbserver" if $dbserver;
     
    445428                return undef;
    446429            }
    447 if (0) {
    448             my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc");
    449 
    450             my $exposures = parse_md_list($metadata);
    451 }
    452430            my $exposures = parse_md_fast($mdcParser, $output);
    453431            my $numExp = @$exposures;
  • tags/ipp-20100602/pstamp/scripts/pstamp_parser_run.pl

    r27897 r28230  
    198198$parse_cmd .= " --verbose" if $verbose;
    199199
    200 my $newState = "run";
     200my $newState;
    201201my $fault;
    202202{
     
    224224    }
    225225
    226     unless ($success) {
     226    if ($success) {
     227        $newState = 'run';
     228    } else {
    227229        $fault = $error_code >> 8;
    228 #        $newState = "stop";
    229230    }
    230231}
     
    234235#
    235236{
    236     my $command = "$pstamptool -updatereq -req_id $req_id -set_state $newState";
     237    my $command = "$pstamptool -updatereq -req_id $req_id";
     238    $command   .= " -set_state $newState" if $newState;
    237239    $command   .= " -set_outdir $outdir";
    238240    $command   .= " -set_reqType $reqType" if $reqType;
  • tags/ipp-20100602/pstamp/scripts/pstampparse.pl

    r28145 r28230  
    361361    my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver);
    362362    if (!$proj_hash) {
    363         print STDERR "project $project not found\n" ;
    364363        foreach $row (@$rowList) {
    365364            insertFakeJobForRow($row, 1, $PSTAMP_UNKNOWN_PRODUCT);
Note: See TracChangeset for help on using the changeset viewer.