IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35364


Ignore:
Timestamp:
Apr 4, 2013, 1:09:34 PM (13 years ago)
Author:
bills
Message:

Implement ACTION = 'PREVIEW' for postage stamp requests

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm

    r34448 r35364  
    167167    my $fields_output;
    168168    {
    169         my $command = "echo $request_file_name | $fields -x 0 EXTNAME EXTVER REQ_NAME ACTION USERNAME EMAIL";
     169        my $command = "echo $request_file_name | $fields -x 0 EXTNAME EXTVER REQ_NAME ACTION EMAIL";
    170170        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    171171            run(command => $command, verbose => $verbose);
     
    187187    if ($extver > 1) {
    188188        $header{ACTION} = $action;
    189         $header{USER} = $username;
    190189        $header{EMAIL} = $email;
    191190    } else {
    192191        $header{ACTION} = $action = "PROCESS";
    193         $header{USERNAME} = 'null';
    194192        $header{EMAIL} = 'null';
    195193    }
    196194
    197     if ($action eq "LIST") {
    198         return (\%header, undef);
    199     } elsif ($action ne "PROCESS") {
    200         die "unexpected request ACTION found: $action in $request_file_name";
     195    if ($action ne "PROCESS" and $action ne 'PREVIEW') {
     196        die "\nunexpected request ACTION found: $action in $request_file_name";
    201197    }
    202198
  • trunk/pstamp/scripts/pstamp_finish.pl

    r34447 r35364  
    107107    my ($header, $rows) = read_request_file($req_file);
    108108
    109     my $action = $header->{ACTION};
    110 
    111     if (!$header or (($action eq 'PROCESS') and !$rows)) {
     109    if (!$header or !$rows) {
    112110        # Since a request got queued, the request file must have been readable at some point
    113111        my_die("failed to read request file $req_file", $req_id, $PS_EXIT_CONFIG_ERROR);
     
    128126
    129127    my $request_fault = 0;
    130     if ($action eq 'PROCESS') {
     128    {
    131129        # The results table definition file
    132130        my ($tdf, $table_def_name) = tempfile ("$outdir/tabledef.XXXX", UNLINK => !$save_temps);
     
    273271            }
    274272        }
    275     } elsif ($action ne 'LIST') {
    276         my_die("Unexpected action $action found", $req_id, $PS_EXIT_PROG_ERROR);
    277     } else {
    278         # pstampparse did all of the work
    279273    }
    280274
  • trunk/pstamp/scripts/pstamp_parser_run.pl

    r34232 r35364  
    158158my $request_fault = $PSTAMP_INVALID_REQUEST;
    159159
     160my $action = 'PROCESS';
     161
    160162if (-r $uri) {
    161163    # run the appropriate parse command to parse the queue the jobs for this request
    162164    # first check the extension header to find the EXTNAME
    163     $request_type = find_request_type($uri);
     165    $request_type = find_request_type($uri, \$action);
    164166
    165167    if ($request_type) {
     
    240242
    241243    if ($success) {
    242         $newState = 'run';
     244        if ($action eq 'PROCESS') {
     245            $newState = 'run';
     246        } elsif ($action eq 'PREVIEW') {
     247            $newState = 'parsed';
     248        } else {
     249            print STDERR "WARNING Ignoring unexpected value for ACTION found in request header: $action\n";
     250        }
    243251    } else {
    244252        $fault = $error_code >> 8;
     
    275283    # find the EXTNAME in the input fits table
    276284    my $file_name = shift;
    277     my $out = `echo $file_name | fields -x 0 EXTNAME`;
     285    my $r_action = shift;
     286
     287    my $out = `echo $file_name | fields -x 0 EXTNAME ACTION`;
    278288
    279289    if ($out) {
    280290        # output from fields is filename value
    281         my ($dummy, $extname) = split " ", $out;
     291        my ($dummy, $extname, $action) = split " ", $out;
     292
     293        $$r_action = $action if ($action);
    282294
    283295        return $extname;
  • trunk/pstamp/scripts/pstampparse.pl

    r35363 r35364  
    411411
    412412    if ($action eq 'LIST') {
     413        # LIST is not allowed by caller. Can't get here.
    413414        return list_targets($rowList);
    414415    }
     
    516517    $row->{need_magic} = $need_magic;
    517518
    518     $num_jobs += queueJobs($mode, \@rowList, $imageList);
     519    $num_jobs += queueJobs($action, \@rowList, $imageList);
    519520
    520521    # if a row slipped through with no jobs add a faulted one
     
    538539    my $image = shift;
    539540    my $need_magic = shift;
    540     my $mode = shift;
     541    my $action = shift;
    541542
    542543    my $rownum = $row->{ROWNUM};
     
    621622    write_params($output_base, $image);
    622623
    623     my $newState = "run";
     624    my $newState = $action eq 'PROCESS' ? "run" : "parsed";
    624625    my $fault = 0;
    625626    my $dep_id;
    626627
    627     queueUpdatesIfNeeded($stage, $image, $option_mask, \$newState, \$fault, \$dep_id);
     628    queueUpdatesIfNeeded($action, $stage, $image, $option_mask, \$newState, \$fault, \$dep_id);
    628629
    629630    my $command = "$pstamptool -addjob  -req_id $req_id -job_type $row->{JOB_TYPE}"
     
    654655sub queueJobs
    655656{
    656     my $mode = shift;
     657    my $action = shift;
    657658    my $rowList = shift;
    658659    my $imageList = shift;
     
    674675        my_die( "error: unexpected number of rows for get_image request: $n", $PS_EXIT_PROG_ERROR) if $n != 1;
    675676
    676         $num_jobs = queueGetImageJobs($firstRow, $imageList, $stage, $need_magic, $mode);
     677        $num_jobs = queueGetImageJobs($firstRow, $imageList, $stage, $need_magic, $action);
    677678
    678679    } else {
     
    702703                my $row = $rowList->[$i];
    703704
    704                 $num_jobs += queueJobForImage($row, $stage, $image, $need_magic, $mode);
     705                $num_jobs += queueJobForImage($row, $stage, $image, $need_magic, $action);
    705706            }
    706707        }
     
    716717    my $stage = shift;
    717718    my $need_magic = shift;
    718     my $mode = shift;
     719    my $action = shift;
    719720
    720721    my $num_jobs = 0;
     
    763764        write_params($output_base, $image);
    764765
    765         my $newState = "run";
     766        my $newState = $action eq 'PROCESS' ? "run" : "parsed";
    766767        my $fault = 0;
    767768        my $dep_id;
    768769
    769         queueUpdatesIfNeeded($stage, $image, $option_mask, \$newState, \$fault, \$dep_id);
     770        queueUpdatesIfNeeded($action, $stage, $image, $option_mask, \$newState, \$fault, \$dep_id);
    770771
    771772        $num_jobs++;
     
    909910sub get_dependent
    910911{
    911     my ($r_jobState, $r_fault, $r_dep_id, $imagedb, $state, $stage, $stage_id, $component, $need_magic) = @_;
     912    my ($action, $r_jobState, $r_fault, $r_dep_id, $imagedb, $state, $stage, $stage_id, $component, $need_magic) = @_;
    912913
    913914    # chipRun's can be in full state if destreaking is necessary
     
    928929    my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb -component $component -outdir $outdir";
    929930    $command .= " -need_magic" if $need_magic;
     931    $command .= ' -hold' if $action eq 'PREVIEW';
    930932
    931933    # compute rlabel for the run.
     
    977979
    978980sub queueUpdatesIfNeeded {
     981    my $action = shift;
    979982    my $stage = shift;
    980983    my $image = shift;
     
    10261029                    # set up to queue an update run
    10271030                    my $require_magic = ($need_magic or $image->{magicked});
    1028                     get_dependent(\$$r_newState, \$$r_fault, $r_dep_id, $image->{imagedb},
     1031                    get_dependent($action, \$$r_newState, \$$r_fault, $r_dep_id, $image->{imagedb},
    10291032                        $run_state, $stage, $image->{stage_id}, $image->{component}, $require_magic );
    10301033                }
Note: See TracChangeset for help on using the changeset viewer.