IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 8, 2011, 2:44:12 PM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20110906
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110906

  • branches/eam_branches/ipp-20110906/ippScripts/scripts/chip_imfile.pl

    r32355 r32630  
    3434my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3535my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     36my $nebrepair = can_run('neb-repair') or (warn "Can't find neb-repair" and $missing_tools = 1);
     37
    3638if ($missing_tools) {
    3739    warn("Can't find required tools.");
     
    4446my ( $exp_id, $chip_id, $class_id, $chip_imfile_id, $uri, $camera, $outroot, $dbname, $run_state, $reduction, $threads, $verbose,
    4547     $no_update, $save_temps, $no_op, $redirect, $magicked, $deburned );
    46 
    47 my $zaplog = 0;
    4848
    4949GetOptions(
     
    6565    'no-op'             => \$no_op,     # Don't do any operations?
    6666    'redirect-output'   => \$redirect,
    67     'zaplog'            => \$zaplog,
    6867    'save-temps'        => \$save_temps, # Save temporary files?
    6968    ) or pod2usage( 2 );
     
    9291}
    9392
    94 my ($logDest, $traceDest);
     93my ($logRule, $traceDest);
    9594if ($run_state eq 'new') {
    96     $logDest = prepare_output("LOG.IMFILE", $outroot, $class_id, $zaplog);
     95    $logRule = "LOG.IMFILE";
    9796    $traceDest = prepare_output("TRACE.IMFILE",  $outroot, $class_id, 1);
    9897} else {
    99     $logDest = prepare_output("LOG.IMFILE.UPDATE", $outroot, $class_id, 1);
     98    $logRule = "LOG.IMFILE.UPDATE";
    10099    $traceDest = prepare_output("TRACE.IMFILE.UPDATE",  $outroot, $class_id, 1);
    101100}
    102101
    103102if ($redirect) {
    104     $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR );
     103    my $logDest = $ipprc->filename($logRule, $outroot, $class_id);
     104
     105    $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR );
     106
    105107    print STDOUT "\n\n";
    106108    print STDOUT "Starting script $0 on $host\n\n";
     
    330332        # get the UNIX version of the (possible) neb: or path: filename
    331333        my $uriReal = $ipprc->file_resolve( $uri );
     334        # Catch errors here
     335        if (!$uriReal) {
     336            my $repair_cmd = "$nebrepair $uri";
     337            my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
     338            unless ($repair_success) {
     339                &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     340            }
     341            $uriReal = $ipprc->file_resolve( $uri );
     342        }
     343           
    332344        &my_die("Unable to resolve $uri on $host", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) if !$uriReal;
    333345
     
    336348        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose);
    337349        unless ($success) {
     350            # Catch errors here
     351            my $repair_cmd = "$nebrepair $uri";
     352            my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
     353            unless ($repair_success) {
     354                &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     355            }
     356            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose);
     357        }
     358        unless ($success) {
    338359            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    339360            &my_die("Unable to perform funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     
    348369            $burntoolTable_uri =~ s/fits$/burn.tbl/;
    349370            $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
     371            if ((!$burntoolTable_uriReal)||(!($ipprc->file_exists($burntoolTable_uri)))) {
     372                my $repair_cmd = "$nebrepair $burntoolTable_uri";
     373                my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
     374                unless ($repair_success) {
     375                    &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     376                }
     377                $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
     378            }
    350379            unless ($ipprc->file_exists($burntoolTable_uri)) {
     380                # Catch errors here
    351381                &my_die("Couldn't find burntool table: $burntoolTable_uri",$exp_id,$chip_id,$class_id, $PS_EXIT_SYS_ERROR);
    352382            }
     
    451481    $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id;
    452482    $command .= " -source_id $source_id" if defined $source_id;
    453     $command .= " -tracedest $traceDest -log $logDest";
     483    $command .= " -tracedest $traceDest";
    454484    $command .= " -dbname $dbname" if defined $dbname;
    455485
     
    727757        &my_die("Couldn't find expected output file: $file",  $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    728758    }
     759    # Funpack to confirm we've really made things correctly
     760    my $diskfile = $ipprc->file_resolve($file);
     761    if ($diskfile =~ /fits/) {
     762        my $funpack  = can_run('funpack') or &my_die ("Can't find funpack", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     763        my $check_command = "$funpack -S $diskfile > /dev/null";
     764        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     765            run(command => $check_command, verbose => $verbose);
     766        if (!$success) {
     767            &my_die("Output file not a valid fits file: $file", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     768        }
     769    }
     770    #####
    729771
    730772    if ($replicate and $neb) {
Note: See TracChangeset for help on using the changeset viewer.