IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 12:49:05 PM (16 years ago)
Author:
eugene
Message:

merging changes from trunk into branches/pap

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/pstamp/scripts/pstamp_parser_run.pl

    r26151 r28003  
    2828my $redirect_output;
    2929my $product;
     30my $outdir;
     31my $label;
    3032my $verbose;
    3133my $dbname;
     
    3638    'uri=s'             =>  \$uri,
    3739    'product=s'         =>  \$product,
     40    'outdir=s'          =>  \$outdir,
     41    'label=s'           =>  \$label,
    3842    'redirect-output'   =>  \$redirect_output,
    3943    'verbose'           =>  \$verbose,
     
    7983}
    8084
    81 # workdir is where all of the files generated for this request are placed
    82 # NOTE: this location needs to be kept in sync with the web interface ( request.php )
    83 my $datestr = strftime "%Y%m%d", gmtime;
    84 my $datedir = "$pstamp_workdir/$datestr";
    85 if (! -e $datedir ) {
    86     mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id,
     85if (!$outdir or ($outdir eq "NULL")) {
     86    # outdir is where all of the files generated for this request are placed
     87    # NOTE: this location needs to be kept in sync with the web interface ( request.php )
     88    my $datestr = strftime "%Y%m%d", gmtime;
     89    my $datedir = "$pstamp_workdir/$datestr";
     90    if (! -e $datedir ) {
     91        mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id,
     92            $PS_EXIT_CONFIG_ERROR);
     93    }
     94
     95    $outdir = "$datedir/$req_id";
     96}
     97
     98if (! -e $outdir ) {
     99    mkdir $outdir or my_die("failed to create working directory $outdir for request id $req_id", $req_id,
    87100        $PS_EXIT_CONFIG_ERROR);
    88101}
    89 
    90 my $workdir = "$datedir/$req_id";
    91 if (! -e $workdir ) {
    92     mkdir $workdir or my_die("failed to create working directory $workdir for request id $req_id", $req_id,
    93         $PS_EXIT_CONFIG_ERROR);
    94 }
     102   
    95103
    96104if ($redirect_output) {
    97     my $logDest = "$workdir/psparse.$req_id.log";
     105    my $logDest = "$outdir/psparse.$req_id.log";
    98106    $ipprc->redirect_output($logDest);
    99107}
     
    106114
    107115my $fn = basename($uri);
    108 my $new_uri = "$workdir/$fn";
     116my $new_uri = "$outdir/$fn";
    109117if ($uri =~ /^http:/) {
    110118    # if the uri is an http uri download the file
     
    116124    }
    117125} elsif ($uri ne $new_uri) {
    118     # put a link to the file into the workdir
     126    # copy the request file into outdir
    119127    if (-e $new_uri) {
     128        # file exists already delete it incase the previous copy is bogus
    120129        unlink $new_uri or my_die("failed to unlink $new_uri", $req_id, $PS_EXIT_UNKNOWN_ERROR);
    121130    }
    122131    if (! copy $uri, $new_uri) {
    123         my_die ("failed to copy request file $uri to workdir $workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR);
     132        my_die ("failed to copy request file $uri to workdir $outdir", $req_id, $PS_EXIT_UNKNOWN_ERROR);
    124133    }
    125134}
     
    146155        if ($request_type eq "PS1_PS_REQUEST") {
    147156            $reqType = 'pstamp';
    148             $parse_cmd = $pstampparse;
     157            $parse_cmd = "$pstampparse";
     158            $parse_cmd .= " --label $label" if $label;
    149159        } elsif ($request_type eq "MOPS_DETECTABILITY_QUERY") {
    150160            $reqType = 'dquery';
    151             $parse_cmd = $dqueryparse;
     161            $parse_cmd = "$dqueryparse";
     162            $parse_cmd .= " --label $label" if $label;
    152163        } else {
    153164            print STDERR "Unknown request type $request_type found in $uri";
     
    169180    # that they sent us a request file that we don't understand
    170181
    171     my $command = "$pstamptool -updatereq -req_id $req_id -state run";
    172     $command   .= " -reqType unknown";
    173     $command   .= " -fault $PS_EXIT_DATA_ERROR";
     182    my $command = "$pstamptool -updatereq -req_id $req_id -set_state run";
     183    $command   .= " -set_reqType unknown";
     184    $command   .= " -set_fault $PS_EXIT_DATA_ERROR";
    174185    $command   .= " -dbname $dbname" if $dbname;
    175186    $command   .= " -dbserver $dbserver" if $dbserver;
     
    182193}
    183194
    184 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --out_dir $workdir --file $uri";
     195$parse_cmd .= " --mode queue_job --req_id $req_id --product $product --outdir $outdir --file $uri";
    185196$parse_cmd .= " --dbname $dbname" if $dbname;
    186197$parse_cmd .= " --dbserver $dbserver" if $dbserver;
     
    190201my $fault;
    191202{
    192     my $error_file_name = "$workdir/parse_error.txt";
     203    my $error_file_name = "$outdir/parse_error.txt";
    193204    # get rid of any error file from previous attempt to parse this request
    194205    unlink $error_file_name if (-e $error_file_name);
     
    215226    unless ($success) {
    216227        $fault = $error_code >> 8;
    217         $newState = "stop";
     228#        $newState = "stop";
    218229    }
    219230}
     
    223234#
    224235{
    225     my $command = "$pstamptool -updatereq -req_id $req_id -state $newState";
    226     $command   .= " -reqType $reqType" if $reqType;
    227     $command   .= " -uri $new_uri" if $new_uri;
    228     $command   .= " -fault $fault" if $fault;
     236    my $command = "$pstamptool -updatereq -req_id $req_id -set_state $newState";
     237    $command   .= " -set_outdir $outdir";
     238    $command   .= " -set_reqType $reqType" if $reqType;
     239    $command   .= " -set_uri $new_uri" if $new_uri;
     240    $command   .= " -set_fault $fault" if $fault;
    229241    $command   .= " -dbname $dbname" if $dbname;
    230242    $command   .= " -dbserver $dbserver" if $dbserver;
     
    265277    carp($msg);
    266278
    267     my $command = "$pstamptool -updatereq -req_id $req_id  -fault $fault";
     279    my $command = "$pstamptool -updatereq -req_id $req_id  -set_fault $fault";
    268280    $command   .= " -dbname $dbname" if $dbname;
    269281    $command   .= " -dbserver $dbserver" if $dbserver;
Note: See TracChangeset for help on using the changeset viewer.