IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29173


Ignore:
Timestamp:
Sep 17, 2010, 2:52:15 PM (16 years ago)
Author:
bills
Message:

allow pstamp_insert_request.pl to handle detectability queries

File:
1 edited

Legend:

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

    r28106 r29173  
    4444
    4545my $pstamptool = can_run('pstamptool')  or (warn "Can't find pstamptool"  and $missing_tools = 1);
    46 my $pstampdump = can_run('pstampdump')  or (warn "Can't find pstampdump"  and $missing_tools = 1);
     46my $fields = can_run('fields')  or (warn "Can't find fields"  and $missing_tools = 1);
    4747
    4848if ($missing_tools) {
     
    5353my ($extname, $extver, $req_name);
    5454{
    55     my $command = "$pstampdump -headeronly $tmp_req_file";
     55    # get the header keywords of interest.
     56    # Note that if it's a pstamp request then REQ_NAME should be defined.
     57    # if it's a detectability query it will not have a REQ_NAME but will have a QUERY_ID
     58    my $command = "echo $tmp_req_file | $fields -x 0 EXTNAME EXTVER REQ_NAME QUERY_ID";
    5659    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    5760        run(command => $command, verbose => $verbose);
     61if (0) {
     62    # stoopid fields doesn't set exit status to zero when it works
    5863    unless ($success) {
    5964        print STDERR @$stderr_buf;
    6065        exit $error_code >> 8;
    6166    }
     67}
    6268    my $output = join "", @$stdout_buf;
    63     ($extname, $extver, $req_name) = split " ", $output;
    64     if ($extname and ($extname ne "PS1_PS_REQUEST")) {
     69    (undef, $extname, $extver, $req_name) = split " ", $output;
     70    if (!$extname or ! (($extname eq "PS1_PS_REQUEST") or ($extname eq "MOPS_DETECTABILITY_QUERY"))) {
    6571        print STDERR "invalid request file\n";
    6672        exit $PS_EXIT_DATA_ERROR;
    6773    }
    6874    if (!defined $req_name) {
    69         print STDERR "invalid request file no REQ_NAME\n";
     75        print STDERR "invalid request file no REQ_NAME or QUERY_ID\n";
    7076        exit $PS_EXIT_DATA_ERROR;
    7177    }
     
    9197my $req_id = 0;
    9298{
    93 
    94     my $command = "$pstamptool -addreq -name $req_name -uri $req_file -ds_id 0";
     99    my $command = "$pstamptool -addreq -uri $req_file -ds_id 0 -name $req_name";
    95100    $command .= " -dbname $dbname" if $dbname;
    96101    $command .= " -dbserver $dbserver" if $dbserver;
Note: See TracChangeset for help on using the changeset viewer.