IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 17, 2010, 10:05:43 AM (16 years ago)
Author:
eugene
Message:

merge from trunk

Location:
branches/eam_branches/ipp-20101205/ippScripts/scripts
Files:
11 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/automate_stacks.pl

    r29919 r30102  
    13551355    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target);
    13561356
    1357     if ($target eq 'OSS') {
     1357    if (($target eq 'OSS')||($target eq 'SweetSpot')) {
    13581358        my $db = init_gpc_db();
    13591359
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/camera_exp.pl

    r29893 r30102  
    378378        $ipprc->file_exists($file);
    379379
    380     if ($replicate and (file_scheme($file) eq 'neb')) {
     380    my $scheme = file_scheme($file);
     381    if ($replicate and $scheme and (file_scheme($file) eq 'neb')) {
    381382        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $cam_id, $PS_EXIT_SYS_ERROR);
    382383    }
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/chip_imfile.pl

    r29950 r30102  
    176176    $ipprc->delete_destreak_backup_file($outputWeight)
    177177        or &my_die("failed to delete existing destreak backup weight file", $exp_id, $chip_id, $class_id, $PS_EXIT_UNKNOWN_ERROR);
     178
     179    # don't do binned images when updating unless we are starting from scratch.
     180    $do_binned_images = 0 unless $dump_config;
    178181}
    179182if ($do_binned_images) {
     
    490493        check_output($configuration, 1) if $dump_config;
    491494        check_output($backmdl, 1) if $outputBackmdlExpect;
    492         check_output($pattern, 1) if $outputPatternExpect;
     495        # allow the pattern file to be missing if run state is update older data doesn't have one
     496        # I should parse the config dump file to calculate the 'Expect' variables
     497        check_output($pattern, 1, $run_state eq 'update') if $outputPatternExpect;
    493498        if ($do_photom) {
    494499            check_output($outputSources, 1);
     
    701706    my $file = shift;
    702707    my $replicate = shift;
     708    my $allow_missing = shift;
    703709
    704710    if (!defined $file) {
     
    706712    }
    707713
    708     &my_die("Couldn't find expected output file: $file",  $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
     714    my $exists = $ipprc->file_exists($file);
     715
     716    if (!$exists) {
     717        if ($allow_missing) {
     718            carp("Couldn't find expected output_file: $file but continuing anyways\n");
     719            return 1;
     720        }
     721        &my_die("Couldn't find expected output file: $file",  $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     722    }
    709723
    710724    if ($replicate and $neb) {
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/dist_bundle.pl

    r29063 r30102  
    6262my $streaksrelease   = can_run('streaksrelease') or (warn "Can't find streaksrelease" and $missing_tools = 1);
    6363my $bgtool   = can_run('bgtool') or (warn "Can't find bgtool" and $missing_tools = 1);
     64my $file_cmd   = can_run('file') or (warn "can't find program file" and $missing_tools = 1);
     65my $zcat   = can_run('zcat') or (warn "can't find program zcat" and $missing_tools = 1);
    6466if ($missing_tools) {
    6567    warn("Can't find required tools.");
     
    526528                    $PS_EXIT_CONFIG_ERROR) if (!$resolved);
    527529
     530    &my_die("config dump file resolved but not accessible: $config_file_rule", $component,
     531                    $PS_EXIT_CONFIG_ERROR) if !$ipprc->file_exists($resolved);
     532
     533    my $mdc_compressed;
     534    {
     535        my $command = "$file_cmd $resolved";
     536        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     537            run(command => $command, verbose => $verbose);
     538        unless ($success) {
     539            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     540            &my_die("Unable to perform $command: $error_code", $component, $error_code);
     541        }
     542        my $output = join "", @$stdout_buf;
     543        # XXX: may need to to make this more robust
     544        $mdc_compressed = ($output =~ /gzip/);
     545    }
     546    my $inName;
     547    if ($mdc_compressed) {
     548        my $tmpfile;
     549        ($tmpfile, $inName) = tempfile( "/tmp/bundle.XXXX", UNLINK => !$save_temps );
     550        close($tmpfile) or &my_die("failed to close $inName", $component, $PS_EXIT_UNKNOWN_ERROR);
     551
     552        my $command = "$zcat $resolved > $inName";
     553        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     554            run(command => $command, verbose => $verbose);
     555        unless ($success) {
     556            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     557            &my_die("Unable to perform $command: $error_code", $component, $error_code);
     558        }
     559
     560
     561    } else {
     562        $inName = $resolved;
     563    }
     564    my $in = open_with_retries($inName);
     565
    528566    # we don't use the mdc parser because the perl parser is way is too slow for complicated config
    529567    # files like this
    530     my $in = open_with_retries($resolved);
    531 
    532568    my $line;
    533569    while ($line = <$in>) {
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/magic_destreak.pl

    r29571 r30102  
    309309        }
    310310
    311         $sources = $ipprc->filename("PSPHOT.OUTPUT",  $path_base, $class_id);
     311        # only destreak cmf file if this is a new run
     312        if ($run_state eq 'new') {
     313            $sources = $ipprc->filename("PSPHOT.OUTPUT",  $path_base, $class_id);
     314        }
    312315
    313316    } elsif ($stage eq "chip_bg") {
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/magic_destreak_defineruns.pl

    r27718 r30102  
    7878    foreach my $label (@labels) {
    7979        my $command = "$magicdstool -definebyquery -stage $stage -workdir $workdir -label $label";
    80         $command .= " -dry_run" if $no_update;
     80        $command .= " -pretend" if $no_update;
    8181        $command .= " -limit $stage_limit" if $stage_limit;
    8282        $command .= " -set_label $label";
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/magic_destreak_revert.pl

    r29573 r30102  
    191191    $image  = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id);
    192192    $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id);
    193     $sources = $ipprc->filename("PSPHOT.OUTPUT", $path_base, $class_id);
    194193
    195194    # we use the mask output from the camera stage for input and replace
     
    204203    }
    205204
     205    # only revert sources if this is a new run, not one being updated
     206    if ($run_state eq 'new') {
     207        $sources = $ipprc->filename("PSPHOT.OUTPUT", $path_base, $class_id);
     208        $bsources = $ipprc->filename("PSPHOT.OUTPUT", $backup_path_base, $class_id);
     209    }
     210
    206211    $bimage  = $ipprc->filename("PPIMAGE.CHIP", $backup_path_base, $class_id);
    207212    # This is somewhat kludgey but it works whether the mask is camera mask or chip mask
     
    209214    $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $class_id);
    210215    $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $class_id);
    211     $bsources = $ipprc->filename("PSPHOT.OUTPUT", $backup_path_base, $class_id);
    212216} elsif ($stage eq "camera") {
    213217    $astrom =  $ipprc->filename("PSASTRO.OUTPUT", $path_base);
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/publish_file.pl

    r29622 r30102  
    4444my ( $pub_id, $camera, $stage, $stage_id, $fileset, $format, $product, $workdir );
    4545my ( $dbname, $verbose, $no_update, $no_op, $save_temps, $redirect );
     46my ( $output_format );
    4647
    4748GetOptions(
     
    5960    'save-temps'        => \$save_temps, # Save temporary files?
    6061    'redirect-output'   => \$redirect,   # Redirect output to log file?
     62    'output_format=i'   => \$output_format, # Output format for ppMops
    6163    ) or pod2usage( 2 );
    6264
     
    191193                     warp_id => $comp->{warp1},
    192194                     diff_id => $comp->{diff_id},
     195                     output_format => $comp->{output_format},
    193196                     direction => 1,
    194197        };
     
    323326
    324327    my $command = "$ppMops $input $output";
    325     $command .= " -version 1"; # XXX : NOTE: for now, MOPS just wants PS1_DV1 (remove this eventually...)
    326328    $command .= " -exp_name " . $data->{exp_name} if defined $data->{exp_name};
    327329    $command .= " -exp_id " . $data->{exp_id} if defined $data->{exp_id};
     
    335337    $command .= " -zp_error " . $data->{zp_err} if defined $data->{zp_err};
    336338    $command .= " -astrom_rms " . $data->{astrom} if defined $data->{astrom};
     339    $command .= " -version " . $data->{output_format} if defined $data->{output_format};
    337340
    338341    unless ($no_op) {
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/receive_file.pl

    r29574 r30102  
    3232my $receivetool = can_run('receivetool') or (warn "Can't find receivetool" and $missing_tools = 1);
    3333my $dsproductls = can_run('dsfilesetls') or (warn "Can't find dsfilesetls" and $missing_tools = 1);
     34my $gunzip = can_run('gunzip') or (warn "Can't find gunzip" and $missing_tools = 1);
    3435if ($missing_tools) {
    3536    warn("Can't find required tools.");
     
    404405    my $workdir = shift;
    405406
     407    my $filecmd_output = `file $src`;
     408    &my_die("failed to determinte file type of $src", $file_id, $PS_EXIT_UNKNOWN_ERROR) if !$filecmd_output;
     409    chomp $filecmd_output;
     410
     411    my $tmpName;
     412    if ($filecmd_output =~ /gzip/) {
     413        my $tmpfile;
     414        ($tmpfile, $tmpName) = tempfile( "/tmp/receive.XXXX", UNLINK => !$save_temps );
     415        close($tmpfile) or &my_die("failed to close $tmpName", $file_id, $PS_EXIT_UNKNOWN_ERROR);
     416
     417        my $command = "$gunzip -c $src > $tmpName";
     418        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     419            run(command => $command, verbose => $verbose);
     420        unless ($success) {
     421            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     422            &my_die("Unable to perform $command: $error_code", $component, $error_code);
     423        }
     424        $src = $tmpName;
     425    }
     426
    406427    open my $IN,  "<$src" or &my_die("failed to open $src for input", $file_id, $PS_EXIT_UNKNOWN_ERROR);
    407428    open my $OUT, ">$dest" or &my_die("failed to open $dest for output", $file_id, $PS_EXIT_UNKNOWN_ERROR);
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/register_exp.pl

    r27891 r30102  
    3030my $regtool = can_run('regtool') or (warn "can't find regtool" and $missing_tools = 1);
    3131my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     32my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3233if ($missing_tools) {
    3334    warn ("Can't find required tools");
     
    118119if (uc($exp_type) eq "NULL") { &my_die ("exp_type  not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
    119120
     121my ($data_group,$dist_group,$chip_workdir,$reduction);
     122($label,$data_group,$dist_group,$end_stage,
     123 $tess_id,$chip_workdir,$reduction) = advance_decisions(&value_for_flag($cmdflags,"-dateobs"),
     124                                                        &value_for_flag($cmdflags,"-exp_type"),
     125                                                        &value_for_flag($cmdflags,"-obs_mode"),
     126                                                        &value_for_flag($cmdflags,"-object"),
     127                                                        &value_for_flag($cmdflags,"-comment"),
     128                                                        $dbname);
    120129my $command = "$regtool -addprocessedexp";
    121130$command .= " -exp_id $exp_id";
     
    127136$command .= " -end_stage $end_stage" if defined $end_stage;
    128137$command .= " -tess_id   $tess_id"   if defined $tess_id;
     138$command .= " -data_group $data_group" if defined $data_group;
     139$command .= " -dist_group $dist_group" if defined $dist_group;
     140$command .= " -chip_workdir $chip_workdir" if defined $chip_workdir;
     141$command .= " -reduction  $reduction"  if defined $reduction;
    129142$command .= " -state full";
    130143$command .= " $cmdflags";
     
    156169
    157170### Pau.
     171sub advance_decisions {
     172    my $dateobs = shift;
     173    my $exptype = shift;
     174    my $obsmode = shift;
     175    my $object  = shift;
     176    my $comment = shift;
     177    my $dbname  = shift;
     178
     179    # The strings come pre-quoted.
     180    $dateobs =~ s/\'//g;
     181    $exptype =~ s/\'//g;
     182    $obsmode =~ s/\'//g;
     183    $object =~ s/\'//g;
     184    $comment =~ s/\'//g;
     185
     186    print "Inside decision engine\n";
     187    my ($label,$data_group,$dist_group,$end_stage,$tess_id,$chip_workdir,$reduction);
     188    my $target;
     189
     190    if ($exptype ne 'OBJECT') {
     191        print "Aborting because exptype doesn't claim to be OBJECT: $exptype\n";
     192        return(undef,undef,undef,"reg",undef,undef,undef);
     193    }
     194    if ($obsmode eq 'ENGINEERING') {
     195        print "Aborting because we don't queue engineering data to chip\n";
     196        return(undef,undef,undef,"reg",undef,undef,undef);
     197    }
     198    # Grab the configuration data.
     199    my %nightlyscience_config = ();
     200    my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -";
     201    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     202        run(command => $conf_cmd, verbose => $verbose);
     203    unless ($success) {
     204        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     205        &my_die("Unable to perform ppConfigDump: $error_code", $date, $PS_EXIT_SYS_ERROR);
     206    }
     207    print "data loaded\n";
     208    my $mdcParser = PS::IPP::Metadata::Config->new;
     209    my $metadata = $mdcParser->parse(join "", @$stdout_buf);
     210    foreach my $entry (@{ $metadata }) {
     211        if (${ $entry }{name} eq 'TARGETS') {
     212            my @target_data = @{ ${ $entry }{value} };
     213            my $this_target = '';
     214            foreach my $tentry (@target_data) {
     215                if (${ $tentry }{name} eq 'NAME') {
     216                    $this_target = ${ $tentry }{value};
     217                    $nightlyscience_config{$this_target}{DISTRIBUTION} = $this_target;
     218                }
     219                elsif (${ $tentry }{name} eq 'DISTRIBUTION') {
     220                    $nightlyscience_config{$this_target}{DISTRIBUTION} = ${ $tentry }{value};
     221                }
     222                elsif (${ $tentry }{name} eq 'TESS') {
     223                    $nightlyscience_config{$this_target}{TESS_ID} = ${ $tentry }{value};
     224                }
     225                elsif (${ $tentry }{name} eq 'OBSMODE') {
     226                    $nightlyscience_config{$this_target}{OBSMODE} = ${ $tentry }{value};
     227                    $nightlyscience_config{$this_target}{OBSMODE} =~ s/%/\.\*/g;
     228                }
     229                elsif (${ $tentry }{name} eq 'OBJECT') {
     230                    $nightlyscience_config{$this_target}{OBJECT} = ${ $tentry }{value};
     231                    $nightlyscience_config{$this_target}{OBJECT} =~ s/%/\.\*/g;
     232                }
     233                elsif (${ $tentry }{name} eq 'COMMENT') {
     234                    $nightlyscience_config{$this_target}{COMMENT} = ${ $tentry }{value};
     235                    $nightlyscience_config{$this_target}{COMMENT} =~ s/%/\.\*/g;
     236                }
     237                elsif (${ $tentry }{name} eq 'STACKABLE') {
     238                    $nightlyscience_config{$this_target}{STACKABLE} = ${ $tentry }{value};
     239                }
     240                elsif (${ $tentry }{name} eq 'DIFFABLE') {
     241                    $nightlyscience_config{$this_target}{DIFFABLE} = ${ $tentry }{value};
     242                }
     243                elsif (${ $tentry }{name} eq 'REDUCTION') {
     244                    $nightlyscience_config{$this_target}{REDUCTION} = ${ $tentry }{value};
     245                }
     246            }
     247        }
     248    }
     249    print "data parsed\n";
     250    my $found_target;
     251    foreach $target (keys %nightlyscience_config) {
     252#       print "TEST: $target ($obsmode $object $comment) ($nightlyscience_config{$target}{OBSMODE} $nightlyscience_config{$target}{OBJECT} $nightlyscience_config{$target}{COMMENT}\t";
     253        my $match = 0;
     254        my $possible = 0;
     255        if (exists($nightlyscience_config{$target}{OBSMODE})) {
     256            $possible++;
     257            if ($obsmode =~ /$nightlyscience_config{$target}{OBSMODE}/) {
     258                $match++;
     259            }
     260        }
     261        if (exists($nightlyscience_config{$target}{OBJECT})) {
     262            $possible++;
     263            if ($object =~ /$nightlyscience_config{$target}{OBJECT}/) {
     264                $match++;
     265            }
     266        }
     267        if (exists($nightlyscience_config{$target}{COMMENT})) {
     268            $possible++;
     269            if ($comment =~ /$nightlyscience_config{$target}{COMMENT}/) {
     270                $match++;
     271            }
     272        }
     273        print "$possible $match\n";
     274        if (($possible > 0)&&($match == $possible)) {
     275            $found_target = $target;
     276            last;
     277        }
     278    }
     279    unless ($found_target) {
     280        print "No acceptible target found.\n";
     281        return(undef,undef,undef,"reg",undef,undef,undef);
     282    }
     283    print "Found this target: $found_target\n";
     284    print "$dateobs\n";
     285    $target = $found_target;
     286   
     287    my $date  = $dateobs;
     288    $date =~ s/T.*//;
     289    my $workdir_date = $date;
     290    $date =~ s/-//g;
     291    $workdir_date =~ s%-%/%g;
     292    print "$dateobs $date $workdir_date\n";   
     293    $label = "${target}.nightlyscience";
     294    $data_group = "${target}.${date}";
     295    $dist_group = $nightlyscience_config{$target}{DISTRIBUTION};
     296    $end_stage  = 'warp';
     297    $tess_id    = $nightlyscience_config{$target}{TESS_ID};
     298    $chip_workdir = "neb://\@HOST\@.0/${dbname}/${target}.nt/${workdir_date}/";
     299    if (exists($nightlyscience_config{$target}{REDUCTION})) {
     300        $reduction  = $nightlyscience_config{$target}{REDUCTION};
     301    }
     302    else {
     303        undef($reduction);
     304    }
     305
     306   
     307    return ($label,$data_group,$dist_group,$end_stage,$tess_id,$chip_workdir,$reduction);
     308}
     309           
     310           
     311           
    158312
    159313sub cache_run
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/register_imfile.pl

    r27891 r30102  
    1919use File::Basename qw( basename);
    2020use IPC::Run;
    21 use IPC::Cmd 0.36 qw( can_run );
     21use IPC::Cmd 0.36 qw( can_run run );
    2222use PS::IPP::Config 1.01 qw( :standard );
     23use PS::IPP::Metadata::List qw( parse_md_list );
    2324use PS::IPP::Metadata::Config;
    2425use Math::Trig;
     
    3536my $ppStatsFromMetadata = can_run( 'ppStatsFromMetadata' ) or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    3637my $ppConfigDump = can_run( 'ppConfigDump' ) or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     38my $ippApplyBurntoolSingle = can_run( 'ipp_apply_burntool_single.pl' ) or (warn "Can't find ipp_apply_burntool_single" and $missing_tools = 1);
    3739
    3840my ($cache, $exp_id, $tmp_class_id, $tmp_exp_name, $uri, $bytes, $md5sum, $dbname, $verbose, $no_update, $no_op, $logfile);
     
    8284
    8385my $cmdflags;
     86my $burntoolStateGood;
    8487# Run ppStats on the input file
    8588{
     
    114117    my $burntoolState = 0;
    115118    my $isGPC1 = 0;
    116     my $burntoolStateGood = 0;
     119    $burntoolStateGood = 0;
    117120    foreach my $line (split /\n/, $out1) {
    118121        if ($line =~ /FPA.BURNTOOL.APPLIED/) {
     
    174177$command .= " -hostname $host" if defined $host;
    175178$command .= " -dbname $dbname" if defined $dbname;
    176 $command .= " -data_state full";
     179$command .= " -data_state check_burntool";
    177180$command .= " $cmdflags";
    178181
     182print "$command\n";
    179183# determine solar-system parameters
    180184my $longitude = &value_for_flag($cmdflags, 0.0, "-longitude");
     
    206210    }
    207211}
     212
     213# This might have a race condition
     214# $date_end = $dateobs;
     215# $date_start = $dateobs - 30 minutes ? dateobs_UTC_midnight?
     216# lock file?
     217# if exp_type = DARK and date > MIDNIGHT HST { wait }
     218# system("ipp_apply_burntool.pl --class_id $class_id --dateobs_begin $date_start --dateobs_end $date_end --dbname gpc1 --logfile /data/$host.0/burntool_logs/$class_id.$start_date.log");
    208219
    209220$now_time = localtime();
     
    222233    print "skipping command: $command\n";
    223234}
     235
     236# We now have an imfile in the database, check if we can burntool it.  If not, continue on.
     237
     238{
     239    my $mdcParser  = PS::IPP::Metadata::Config->new;
     240
     241    my $class_id   = &value_for_flag($cmdflags, 0.0, "-class_id");
     242    my $check_date       = &value_for_flag($cmdflags, 0.0, "-dateobs");
     243    $check_date =~ s/T.*$//;
     244    my $exp_name   = $tmp_exp_name;
     245   
     246
     247    my $bt_check_command = "$regtool -checkburntoolimfile ";
     248    $bt_check_command .= " -class_id $class_id ";
     249    $bt_check_command .= " -date $check_date ";
     250    $bt_check_command .= " -valid_burntool $burntoolStateGood ";
     251    $bt_check_command .= " -exp_name $exp_name ";
     252    $bt_check_command .= " -dbname $dbname" if defined $dbname;
     253
     254    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     255        run ( command => $bt_check_command, verbose => $verbose);
     256    unless ($success) {
     257        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     258        &my_die("Unable to perform regtool: $error_code",
     259                $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR);
     260    }
     261
     262    my @whole = split /\n/, (join "", @$stdout_buf);
     263    my @single = ();
     264    my $exposures;
     265    while ( scalar @whole > 0 ) {
     266        my $value = shift @whole;
     267        push @single, $value;
     268        if ($value =~ /^\s*END\s*$/) {
     269            push @single, "\n";
     270           
     271            my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) );
     272            &my_die("Unable to parse output from regtool",
     273                    $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR) unless
     274                        defined $list;
     275            push @{ $exposures }, @$list;
     276            @single = ();
     277        }
     278    }
     279   
     280    # We only care about the final entry, as that contains the exposure we are.
     281   
     282    my $regtool_update = "$regtool -updateprocessedimfile ";
     283    $regtool_update .= "-dbname $dbname " if defined $dbname;
     284    $regtool_update .= "-exp_id $exp_id -class_id $class_id ";
     285
     286    my $burntool_data = pop(@{ $exposures });
     287    if ($burntool_data->{burnable} == 0) {
     288        $regtool_update .= " -burntool_state 0 -set_state pending_burntool ";
     289    }
     290    else {
     291        my $apply_command = "$ippApplyBurntoolSingle --dbname $dbname ";
     292        $apply_command .= " --class_id $class_id --exp_id $exp_id ";
     293        $apply_command .= " --this_uri $burntool_data->{uri} ";
     294        $apply_command .= " --previous_uri $burntool_data->{previous_uri} " if defined $burntool_data->{previous_uri};
     295        $apply_command .= " --imfile_state $burntool_data->{imfile_state} ";
     296        $apply_command .= " --verbose " if $verbose;
     297        print "$apply_command\n";
     298        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     299            IPC::Cmd::run(command => $apply_command, verbose => $verbose);
     300        unless ($success) {
     301            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     302            warn ("Unable to perform ipp_apply_burntool_single.pl: $error_code");
     303            exit($error_code);
     304        }
     305    }   
     306
     307    unless ($no_update) {
     308        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     309            IPC::Cmd::run(command => $regtool_update, verbose => $verbose);
     310        unless ($success) {
     311            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     312            warn ("Unable to perform regtool -addprocessedimfile: $error_code");
     313            exit($error_code);
     314        }
     315    } else {
     316        print "skipping command: $command\n";
     317    }
     318
     319}
     320
     321
    224322
    225323$now_time = localtime();
Note: See TracChangeset for help on using the changeset viewer.