IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 23, 2011, 11:40:28 AM (15 years ago)
Author:
bills
Message:

if reading a file fails check for existence of instance and empty file.
Then try neb-repair on it

File:
1 edited

Legend:

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

    r32749 r32779  
    3232my $listvideocells = can_run('listvideocells.pl') or (warn "Can't find listvideocells.pl" and $missing_tools = 1);
    3333my $dsreg = can_run('dsreg') or (warn "Can't find dsreg" and $missing_tools = 1);
     34my $nebrepair = can_run('neb-repair') or (warn "Can't find neb-repair" and $missing_tools = 1);
    3435if ($missing_tools) {
    3536    warn("Can't find required tools.");
     
    116117        run(command => $command, verbose => $verbose);
    117118    unless ($success) {
     119        check_input_file($uri, $vp_id, $class_id, 'nocell');
    118120        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    119121        &my_die("Unable to perform $command: $error_code", $vp_id, $error_code);
     
    135137                run(command => $command, verbose => $verbose);
    136138            unless ($success) {
     139                check_input_file($uri, $vp_id, $class_id, $cell_id);
    137140                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    138141                &my_die("Unable to perform psvideophot: $error_code", $vp_id, $error_code);
     
    244247exit 0;
    245248
     249sub check_input_file {
     250    my $uri = shift;
     251    my $vp_id = shift;
     252    my $class_id = shift;
     253    my $cell_id = shift;
     254    my $resolved = $ipprc->file_resolve($uri);
     255
     256    my $tryrepair = 0;
     257    if (!-e $resolved) {
     258        printf STDERR "instance $resolved for $uri does not exist\n";
     259        $tryrepair = 1;
     260    } elsif (-s $resolved == 0) {
     261        printf STDERR "instance $resolved for $uri is empty\n";
     262        $tryrepair = 1;
     263    }
     264    if ($tryrepair) {
     265        my $scheme = file_scheme($uri);
     266        if ($scheme and ($scheme = 'neb')) {
     267            my $command = "$nebrepair $uri";
     268            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     269                run(command => $command, verbose => $verbose);
     270            unless ($success) {
     271                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     272                my $err_message = "Unable to perform nebrepair";
     273                &my_die("$err_message: $error_code", $vp_id, $error_code);
     274            }
     275       }
     276    }
     277}
     278
    246279sub my_die
    247280{
Note: See TracChangeset for help on using the changeset viewer.