IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 24, 2009, 12:00:25 PM (17 years ago)
Author:
Paul Price
Message:

Adding handling for missed exceptions, similar to register_imfile.pl --- the idea is to have exceptions trigger the my_die functions so that errors are recorded in the database, and don't go on forever.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/magic_process.pl

    r21371 r22430  
    2828use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2929use Pod::Usage qw( pod2usage );
     30
     31# Look for programs we need
     32my $missing_tools;
     33my $magictool      = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
     34my $removestreaks = can_run('RemoveStreaks') or (warn "Can't find RemoveStreaks" and $missing_tools = 1);
     35if ($missing_tools) {
     36    warn("Can't find required tools.");
     37    exit($PS_EXIT_CONFIG_ERROR);
     38}
    3039
    3140# Parse the command-line arguments
     
    5362    defined $outroot;
    5463
     64# Unhandled exceptions should be passed on to my_die so they get pushed into the database
     65$SIG{__DIE__} = sub { die @_ if $^S;
     66                      my_die( $_[0], $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR ); };
     67
    5568$ipprc->define_camera($camera);
    5669
     
    6679# resolve any path:// or file:// in outroot
    6780$outroot = $ipprc->file_resolve($outroot);
    68    
     81
    6982$ipprc->redirect_output($logfile) if $logfile;
    70 
    71 # Look for programs we need
    72 my $missing_tools;
    73 my $magictool      = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
    74 my $removestreaks = can_run('RemoveStreaks') or (warn "Can't find RemoveStreaks" and $missing_tools = 1);
    75 if ($missing_tools) {
    76     warn("Can't find required tools.");
    77     exit($PS_EXIT_CONFIG_ERROR);
    78 }
    7983
    8084my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    145149        # this causes major file pollution, but avoids multi-level queries
    146150        # at higher level nodes.
    147        
     151
    148152        my ($in_fh, $input_list)  = open_list_file($outroot, "input.list");
    149153        print $in_fh "$outroot\n";
     
    252256
    253257    my $fh;
    254     open $fh, "<$resolved" or 
     258    open $fh, "<$resolved" or
    255259        &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
    256260    # the first line in the streaks file contains the number of streaks found
     
    259263    close $fh;
    260264    print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose;
    261    
     265
    262266    my $command = "$magictool -addmask";
    263267    $command   .= " -magic_id $magic_id";
Note: See TracChangeset for help on using the changeset viewer.