IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29909


Ignore:
Timestamp:
Dec 3, 2010, 5:48:46 PM (15 years ago)
Author:
watersc1
Message:

Forgot the scripts

Location:
branches/czw_branch/20101203/ippScripts/scripts
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20101203/ippScripts/scripts/register_imfile.pl

    r27891 r29909  
    3535my $ppStatsFromMetadata = can_run( 'ppStatsFromMetadata' ) or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    3636my $ppConfigDump = can_run( 'ppConfigDump' ) or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     37my $ippApplyBurntoolSingle = can_run( 'ipp_apply_burntool_single.pl' ) or (warn "Can't find ipp_apply_burntool_single" and $missing_tools = 1);
    3738
    3839my ($cache, $exp_id, $tmp_class_id, $tmp_exp_name, $uri, $bytes, $md5sum, $dbname, $verbose, $no_update, $no_op, $logfile);
     
    8283
    8384my $cmdflags;
     85my $burntoolStateGood;
    8486# Run ppStats on the input file
    8587{
     
    114116    my $burntoolState = 0;
    115117    my $isGPC1 = 0;
    116     my $burntoolStateGood = 0;
     118    $burntoolStateGood = 0;
    117119    foreach my $line (split /\n/, $out1) {
    118120        if ($line =~ /FPA.BURNTOOL.APPLIED/) {
     
    174176$command .= " -hostname $host" if defined $host;
    175177$command .= " -dbname $dbname" if defined $dbname;
    176 $command .= " -data_state full";
     178$command .= " -data_state check_burntool";
    177179$command .= " $cmdflags";
    178180
     
    206208    }
    207209}
     210
     211# This might have a race condition
     212# $date_end = $dateobs;
     213# $date_start = $dateobs - 30 minutes ? dateobs_UTC_midnight?
     214# lock file?
     215# if exp_type = DARK and date > MIDNIGHT HST { wait }
     216# 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");
    208217
    209218$now_time = localtime();
     
    222231    print "skipping command: $command\n";
    223232}
     233
     234# We now have an imfile in the database, check if we can burntool it.  If not, continue on.
     235
     236{
     237    my $bt_check_command = "$regtool -checkburntoolimfile ";
     238    $bt_check_command = " -class_id $class_id ";
     239    $bt_check_command = " -date $date ";
     240    $bt_check_command = " -exp_name $exp_name ";
     241    $bt_check_command = " -dbname $dbname" if defined $dbname;
     242
     243    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     244        run ( command => $bt_check_command, verbose => $verbose);
     245    unless ($success) {
     246        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     247        &my_die("Unable to perform regtool: $error_code",
     248                $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR);
     249    }
     250
     251    my @whole = split /\n/, (join "", @$stdout_buf);
     252    my @single = ();
     253    my $exposures;
     254    while ( scalar @whole > 0 ) {
     255        my $value = shift @whole;
     256        push @single, $value;
     257        if ($value =~ /^\s*END\s*$/) {
     258            push @single, "\n";
     259           
     260            my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) );
     261            &my_die("Unable to parse output from regtool",
     262                    $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR) unless
     263                        defined $list;
     264            push @{ $exposures }, @$list;
     265            @single = ();
     266        }
     267    }
     268   
     269    # We only care about the final entry, as that contains the exposure we are.
     270   
     271    my $regtool_update = "$regtool -updateprocessedimfile ";
     272    $regtool_update .= "-dbname $dbname" if defined $dbname;
     273    $regtool_update .= "-exp_id $exp_id -class_id $class_id ";
     274
     275    my $burntool_data = pop(@{ $exposures });
     276    if ($burntool_data->{burnable} == 0) {
     277        $regtool_update .= " -burntool_state 0 -data_state pending_burntool ";
     278    }
     279    else {
     280        my $apply_command = "$ippApplyBurntoolSingle --dbname $dbname ";
     281        $apply_command .= " --class_id $class_id --exp_id $exp_id ";
     282        $apply_command .= " --this_uri $burntool_data->{this_uri} ";
     283        $apply_command .= " --previous_uri $burntool_data->{previous_uri} " if defined $burntool_data->{previous_uri};
     284        $apply_command .= " --imfile_state $burntool_data->{imfile_state} ";
     285        $apply_command .= " --verbose " if $verbose;
     286        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     287            IPC::Cmd::run(command => $apply_command, verbose => $verbose);
     288        unless ($success) {
     289            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     290            warn ("Unable to perform ipp_apply_burntool_single.pl: $error_code");
     291            exit($error_code);
     292        }
     293    }   
     294
     295    unless ($no_update) {
     296        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     297            IPC::Cmd::run(command => $regtool_update, verbose => $verbose);
     298        unless ($success) {
     299            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     300            warn ("Unable to perform regtool -addprocessedimfile: $error_code");
     301            exit($error_code);
     302        }
     303    } else {
     304        print "skipping command: $command\n";
     305    }
     306
     307}
     308
     309
    224310
    225311$now_time = localtime();
Note: See TracChangeset for help on using the changeset viewer.