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/chip_imfile.pl

    r21371 r22430  
    2525use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2626use Pod::Usage qw( pod2usage );
     27
     28# Look for programs we need
     29my $missing_tools;
     30my $chiptool = can_run('chiptool') or (warn "Can't find chiptool" and $missing_tools = 1);
     31my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     32my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     33my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     34if ($missing_tools) {
     35    warn("Can't find required tools.");
     36    exit($PS_EXIT_CONFIG_ERROR);
     37}
    2738
    2839# Parse the command-line arguments
     
    5364    defined $chip_id and
    5465    defined $class_id and
    55     defined $chip_imfile_id and 
     66    defined $chip_imfile_id and
    5667    defined $uri and
    5768    defined $camera and
    5869    defined $outroot and
    5970    defined $run_state;
     71
     72# Unhandled exceptions should be passed on to my_die so they get pushed into the database
     73$SIG{__DIE__} = sub { die @_ if $^S;
     74                      my_die( $_[0], $exp_id, $chip_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
    6075
    6176$ipprc->define_camera($camera);
     
    6984    print STDOUT "Starting script $0 on $host\n\n";
    7085    print STDOUT "COMMAND IS: @ARGV\n\n";
    71 }
    72 
    73 # Look for programs we need
    74 my $missing_tools;
    75 my $chiptool = can_run('chiptool') or (warn "Can't find chiptool" and $missing_tools = 1);
    76 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
    77 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    78 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    79 if ($missing_tools) {
    80     warn("Can't find required tools.");
    81     exit($PS_EXIT_CONFIG_ERROR);
    8286}
    8387
     
    132136        $command .= " -threads $threads" if defined $threads;
    133137        $command .= " -dbname $dbname" if defined $dbname;
    134         $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id;
    135         $command .= " -source_id $source_id" if defined $source_id;
     138        $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id;
     139        $command .= " -source_id $source_id" if defined $source_id;
    136140        $command .= " -dumpconfig $configuration";
    137141        $command .= " -tracedest $traceDest -log $logDest";
     
    142146        $command .= " -threads $threads" if defined $threads;
    143147        $command .= " -dbname $dbname" if defined $dbname;
    144         $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id;
    145         $command .= " -source_id $source_id" if defined $source_id;
     148        $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id;
     149        $command .= " -source_id $source_id" if defined $source_id;
    146150        $command .= " -tracedest $traceDest -log $logDest";
    147151        $command .= " -Db PPIMAGE:PHOTOM FALSE";
Note: See TracChangeset for help on using the changeset viewer.