IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18544


Ignore:
Timestamp:
Jul 15, 2008, 10:11:04 AM (18 years ago)
Author:
bills
Message:

significant changes to the way jobs are processed.

File:
1 edited

Legend:

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

    r18235 r18544  
    1111use Sys::Hostname;
    1212use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     13use File::Basename;
     14use Digest::MD5::File qw( file_md5_hex );
     15
     16# values for OPTION_MASK
     17# XXX put these in a module
     18use constant PSTAMP_SELECT_IMAGE  => 1;
     19use constant PSTAMP_SELECT_MASK   => 2;
     20use constant PSTAMP_SELECT_WEIGHT => 4;
     21
    1322
    1423my $verbose;
     
    92101}
    93102
     103my $rownum = $psjob->{rownum};
    94104my $uri = $psjob->{uri};
    95105my $outputBase = $psjob->{outputBase};
     
    105115
    106116    if ($success) {
     117        # XXX shouldn't need to do this, review schema`
     118        my $dir = dirname($outputBase);
     119
     120        my $reglist = "$dir/reglist$job_id";
     121
     122        open F, ">$reglist" or die "can't open $reglist for output";
     123
     124        # we are assuming an interface with ppstamp here.
     125        my @extensions = ( "fits", "mk.fits", "wt.fits");
     126
     127        # XXX TODO: add mask of expected file types to pstampJob so we know what to expect
     128
     129        my $output_mask = PSTAMP_SELECT_IMAGE;
     130        my $m = 1;  # XXX we're getting a bit intimate with the bit field definitions here. do better use a hash
     131        foreach my $extension (@extensions) {
     132            my $do_this_one = $m & $output_mask;
     133            $m = $m << 1;
     134            next if (! $do_this_one);
     135
     136            my $basename = basename($outputBase);
     137
     138            my $filename = "${basename}.${extension}";
     139            my $path  = "${outputBase}.${extension}";
     140
     141            # XXX is pstamp always the right file type, if not where can we get the right one?
     142            print F file_registration_line($filename, $path, "pstamp") . "\n";
     143        }
     144
     145        close F;
    107146        $jobStatus = $PS_EXIT_SUCCESS;
    108147    } else {
     
    111150    }
    112151} elsif ($jobType eq "get_image") {
    113     my $command = "$pstamp_get_image_job --uri $uri --out_dir $outputBase";
    114     $command .= " -dbname $dbname" if $dbname;
     152    my $command = "$pstamp_get_image_job --job_id $job_id --uri $uri --out_dir $outputBase --rownum $rownum";
     153    $command .= " --dbname $dbname" if $dbname;
    115154    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    116155        run(command => $command, verbose => $verbose);
     
    126165}
    127166
    128 
    129167# stop the job and set the result value
    130168{
    131     my $command = "$pstamptool -processedjob -job_id $job_id -state stop -result $jobStatus";
     169    my $command = "$pstamptool -processedjob -job_id $job_id -state stop -fault $jobStatus";
    132170    $command .= " -dbname $dbname" if $dbname;
    133171    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    139177
    140178exit $jobStatus;
     179
     180# XXX move this to a module so it can be shared
     181sub file_registration_line {
     182    my $filename = shift;
     183    my $path     = shift;
     184    my $filetype = shift;
     185    if (-e $path) {
     186        my @finfo = stat($path);
     187        die "failed to stat $path" unless (@finfo);    # XXX clean up
     188        my $bytes = $finfo[7];
     189        my $md5sum = file_md5_hex($path);
     190
     191        return "$filename|$bytes|$md5sum|$filetype|";
     192    } else {
     193        die "$filename not found at $path";
     194    }
     195}
Note: See TracChangeset for help on using the changeset viewer.