IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 23, 2011, 2:59:12 PM (15 years ago)
Author:
heather
Message:

more debugging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/haf_add201112/ippScripts/scripts/mergedvodb_merge.pl

    r32989 r33021  
    4141}
    4242
    43 my ( $mergedvodb_path, $merge_id, $minidvodb_path, $dbname,$camera,$verbose, $logfile, $no_op, $redirect, $save_temps);
     43my ( $mergedvodb_path, $merge_id, $mergedvodb, $minidvodb_path, $dbname,$camera,$verbose, $logfile, $no_op, $redirect, $save_temps);
    4444GetOptions(
    4545    'mergedvodb_path|w=s'         => \$mergedvodb_path,  # output DVO database
    4646    'minidvodb_path|w=s'     => \$minidvodb_path, #minidvodb database
     47    'mergedvodb|w=s'    => \$mergedvodb, #mergedvodb
    4748    'merge_id|w=s'  => \$merge_id, #minidvodb_id
    4849    'dbname|d=s'        => \$dbname, # Database name
     
    5657pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    5758pod2usage(
    58           -msg => "Required options: --merge_id -- minidvodb_path --mergedvodb --camera",
     59          -msg => "Required options: --merge_id -- minidvodb_path --mergedvodb_path --mergedvodb --camera",
    5960          -exitval => 3,
    6061          ) unless
     62    defined $mergedvodb_path and
     63    defined $minidvodb_path and
    6164    defined $mergedvodb and
    62     defined $minidvodb_path and
    6365    defined $merge_id and
    6466    defined $camera;
     
    7880unless ($no_op) {
    7981
    80         #this is chopped into several parts: firstcheck, addstar, relphot, dvoverify, merge
    81        
    82         #first check that there were no faulted merges before. If there are, fault this merge with PS_EXIT_UNKNOWN_ERROR
    83         {
    84             my $nothing_faulted = 0;
    85             my $mdcParser = PS::IPP::Metadata::Config->new;
    86 
    87             my $command = "$mergetool -listmerged -faulted -mergedvodb" . $mergedvodb;
    88             $command .= " -dbname $dbname" if defined $dbname;
    89 
    90             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    91                     run(command => $command, verbose => $verbose);
    92             &my_die( "Unable to get list of faulted mergedvodbs", $merge_id, $PS_EXIT_SYS_ERROR) unless $success;
    93             if (scalar @$stdout_buf == 0 ) { #it lists nothing if nothign has faulted
    94                 $nothing_faulted =1;
    95                 print "previous merges are okay.\n";
    96             }
    97             &my_die( "Previous merges faulted, do not proceed until they are investigated:", $minidvodb_group, $PS_EXIT_UNKNOWN_ERROR) unless $nothing_faulted;
    98 
    99 
    100  
    101         }
    102 
    103         {
    104             my $command  = "$dvoverify -s $minidvodb_path";
    105             print "$command\n";
    106             my $mjd_dvoverify_start = DateTime->now->mjd;   # MJD of starting script
    107 
    108             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    109                 run(command => $command, verbose => $verbose);
    110             unless ($success) {
    111                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    112                 &my_die("Unable to perform dvoverify: $error_code", $merge_id, $error_code);
    113             }
    114             $dtime_verify = 86400.0*(DateTime->now->mjd - $mjd_dvoverify_start);   # MJD of starting script
    115             print "dvoverify time $dtime_verify\n";
    116         }
    117 
    118 
    119         #Merge
    120 
    121         my $this_is_the_first;
    122         {
    123 
    124             my $mdcParser = PS::IPP::Metadata::Config->new;
    125 
    126             my $command = "$mergetool -listmerged -state full -mergedvodb " . $mergedvodb;
    127             $command .= " -dbname $dbname" if defined $dbname;
    128 
    129             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    130                     run(command => $command, verbose => $verbose);
    131             &my_die( "Unable to get list of mergedvodbruns", $merge_id, $PS_EXIT_SYS_ERROR) unless $success;
    132             if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
    133                 $this_is_the_first =1;
    134                 print "listing nothing\n";
    135             } else {
    136                 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    137                     &my_die("Unable to parse metadata config", $merge_id, $PS_EXIT_PROG_ERROR);
    138                 #this fails if there is nothing listed. I checked.
    139                 my $components = parse_md_list($metadata) or
    140                     &my_die("Unable to parse metadata list", $merge_id, $PS_EXIT_PROG_ERROR);
    141                 my $comp = $$components[0];
    142                 my  $mergedvodb_path_tmp = $comp->{mergedvodb_path};
    143 
    144                 if (!defined($mergedvodb_path_tmp)) {
    145                     &my_die("Unable to parse mergedvodb_path", $merge_id, $PS_EXIT_PROG_ERROR);
    146                 } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk.
    147                 print "found at least 1 mergedvodbrun in merged state\n";
    148                 $this_is_the_first = 0;
    149             }
    150         }
    151         print "$this_is_the_first $mergedvodb_path/Image.dat\n";
     82    #this is chopped into several parts: firstcheck, addstar, relphot, dvoverify, merge
     83   
     84    #first check that there were no faulted merges before. If there are, fault this merge with PS_EXIT_UNKNOWN_ERROR
     85    {
     86        my $nothing_faulted = 0;
     87        my $mdcParser = PS::IPP::Metadata::Config->new;
     88        my $command = "$mergetool -listmerged -faulted -mergedvodb " . $mergedvodb;
     89        $command .= " -dbname $dbname" if defined $dbname;
     90        print "looking for faulted:\n\n$command\n\n";
     91        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     92            run(command => $command, verbose => $verbose);
     93        &my_die( "Unable to get list of faulted mergedvodbs", $merge_id, $PS_EXIT_SYS_ERROR) unless $success;
     94        if (scalar @$stdout_buf == 0 ) { #it lists nothing if nothign has faulted
     95            $nothing_faulted =1;
     96            print "previous merges are okay.\n";
     97        }
     98        &my_die( "Previous merges faulted, do not proceed until they are investigated:", $merge_id, $PS_EXIT_UNKNOWN_ERROR) unless $nothing_faulted;
     99    }
     100    {
     101        my $command  = "$dvoverify -s $minidvodb_path";
     102        print "$command\n";
     103        my $mjd_dvoverify_start = DateTime->now->mjd;   # MJD of starting script
     104        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     105            run(command => $command, verbose => $verbose);
     106        unless ($success) {
     107            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     108            &my_die("Unable to perform dvoverify: $error_code", $merge_id, $error_code);
     109        }
     110        $dtime_verify = 86400.0*(DateTime->now->mjd - $mjd_dvoverify_start);   # MJD of starting script
     111        print "dvoverify time $dtime_verify\n";
     112    }
     113    #Merge
     114   
     115    my $this_is_the_first;
     116    {
    152117       
    153          
    154         if (-e "$mergedvodb_path/Image.dat") {
    155             if ($this_is_the_first == 1) {
    156                 &my_die("refusing to merge, this is the first, but files already exist in dir", $merge_id, 4);
    157             }
    158             $this_is_the_first =0;
    159         }
     118        my $mdcParser = PS::IPP::Metadata::Config->new;
     119        my $command = "$mergetool -listmerged -mergedvodb " . $mergedvodb;
     120        $command .= " -dbname $dbname" if defined $dbname;
     121        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     122            run(command => $command, verbose => $verbose);
     123        &my_die( "Unable to get list of mergedvodbruns", $merge_id, $PS_EXIT_SYS_ERROR) unless $success;
     124        if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
     125            $this_is_the_first =1;
     126            print "listing nothing\n";
     127        } else {
     128            my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     129                &my_die("Unable to parse metadata config", $merge_id, $PS_EXIT_PROG_ERROR);
     130            #this fails if there is nothing listed. I checked.
     131            my $components = parse_md_list($metadata) or
     132                &my_die("Unable to parse metadata list", $merge_id, $PS_EXIT_PROG_ERROR);
     133            my $comp = $$components[0];
     134            my  $mergedvodb_path_tmp = $comp->{mergedvodb_path};
     135           
     136            if (!defined($mergedvodb_path_tmp)) {
     137                &my_die("Unable to parse mergedvodb_path", $merge_id, $PS_EXIT_PROG_ERROR);
     138            } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk.
     139            print "found at least 1 mergedvodbrun in merged state\n";
     140            $this_is_the_first = 0;
     141        }
     142    }
     143    print "$this_is_the_first $mergedvodb_path/Image.dat\n";
     144    if (-e "$mergedvodb_path/Image.dat") {
     145        if ($this_is_the_first == 1) {
     146            &my_die("refusing to merge, this is the first, but files already exist in dir", $merge_id, 4);
     147        }
     148        $this_is_the_first =0;
     149    }
    160150       
    161         print "$this_is_the_first $mergedvodb_path/Image.dat\n";
    162         {
    163             my $merge_command;
    164             my $mjd_merge_start = DateTime->now->mjd;   # MJD of starting script
    165             if ($this_is_the_first) {
    166                
    167                 $merge_command = "rsync -rvat $minidvodb_path/* $mergedvodb_path";
    168             } else {
    169                 $merge_command = "$dvomerge $minidvodb_path into $mergedvodb_path";
    170             }
    171            
    172             print "\n$merge_command\n";
    173             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    174                 run(command => $merge_command, verbose => $verbose);
    175             unless ($success) {
    176                     $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    177                     &my_die("Unable to merge: $error_code", $merge_id, $error_code);
    178             }
    179                
    180             $dtime_merge = 86400.0*(DateTime->now->mjd - $mjd_merge_start);   # MJD of starting script
    181             print "merge time $dtime_merge\n";
     151    print "$this_is_the_first $mergedvodb_path/Image.dat\n";
     152    {
     153        my $merge_command;
     154        my $mjd_merge_start = DateTime->now->mjd;   # MJD of starting script
     155        if ($this_is_the_first) {
     156            $merge_command = "rsync -rvat $minidvodb_path/* $mergedvodb_path";
     157        } else {
     158            $merge_command = "$dvomerge $minidvodb_path into $mergedvodb_path";
     159        }
     160        print "\n$merge_command\n";
     161        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     162            run(command => $merge_command, verbose => $verbose);
     163        unless ($success) {
     164            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     165            &my_die("Unable to merge: $error_code", $merge_id, $error_code);
     166        }
     167        $dtime_merge = 86400.0*(DateTime->now->mjd - $mjd_merge_start);   # MJD of starting script
     168        print "merge time $dtime_merge\n";
    182169#       }
    183         }
    184 
    185         {
    186 
    187             $dtime_script = 86400.0*(DateTime->now->mjd - $mjd_start);
    188 
    189 
    190             my $command = "mergetool -merge_id $merge_id";
    191             $command .= " -addmerged";
    192             $command .= " -mergedvodb_path $mergedvodb_path" if defined $mergedvodb_path;
    193             $command .= " -dtime_merge $dtime_merge" if defined $dtime_merge;
    194             $command .= " -dtime_script $dtime_script" if defined $dtime_script;
    195             $command .= " -dtime_verify $dtime_verify" if defined $dtime_verify;
    196             $command .= " -dbname $dbname" if defined $dbname;
    197             #print $command;
    198 
    199             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    200                 run(command => $command, verbose => $verbose);
    201             unless ($success) {
    202                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    203                 &my_die("Unable to add to mergedvodbprocessed: $error_code", $merge_id, $error_code);
    204             }
    205         }
    206 
    207     } else {
    208         &my_die("dvodb: $mergedvodb_path not found", $merge_id, $PS_EXIT_UNKNOWN_ERROR);
    209     }
    210 } else {
     170    }
     171
     172    {
     173
     174        $dtime_script = 86400.0*(DateTime->now->mjd - $mjd_start);
     175        my $command = "mergetool -merge_id $merge_id";
     176        $command .= " -addmerged";
     177        $command .= " -mergedvodb $mergedvodb" if defined $mergedvodb;
     178#       $command .= " -mergedvodb_path $mergedvodb_path" if defined $mergedvodb_path;
     179        $command .= " -dtime_merge $dtime_merge" if defined $dtime_merge;
     180        $command .= " -dtime_script $dtime_script" if defined $dtime_script;
     181        $command .= " -dtime_verify $dtime_verify" if defined $dtime_verify;
     182        $command .= " -dbname $dbname" if defined $dbname;
     183        #print $command;
     184       
     185        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     186            run(command => $command, verbose => $verbose);
     187        unless ($success) {
     188            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     189            &my_die("Unable to add to mergedvodbprocessed: $error_code", $merge_id, $error_code);
     190        }
     191    }
     192   
     193#} else {
     194#    &my_die("dvodb: $mergedvodb_path not found", $merge_id, $PS_EXIT_UNKNOWN_ERROR);
     195}
     196else {
    211197    print "skipping processing for $mergedvodb_path\n";
    212198}
    213 
     199   
    214200exit 0;
    215201
     
    218204{
    219205    my $msg = shift; # Warning message on die
    220     my $minidbvodb_id = shift;
     206    my $merge_id = shift;
    221207    my $exit_code = shift; # Exit code to add
    222208
    223209    print STDERR "$msg $mergedvodb_path\n";
    224210
    225 if (defined $minidvodb_id ) {
     211if (defined $merge_id ) {
    226212
    227213    my $command = "mergetool -merge_id $merge_id";
    228214    $command .= " -addmerged";
     215    $command .= " -mergedvodb $mergedvodb" if defined $mergedvodb;
    229216        $command .= " -fault $exit_code";
    230         $command .= " -mergedvodb_path $mergedvodb_path" if defined $mergedvodb_path;
     217        #$command .= " -mergedvodb_path $mergedvodb_path" if defined $mergedvodb_path;
    231218        $command .= " -dtime_merge $dtime_merge" if defined $dtime_merge;
    232219    $command .= " -dtime_script $dtime_script" if defined $dtime_script;
     
    236223
    237224
    238     #print $command;
     225    print $command;
    239226    system ($command);
    240227    }
Note: See TracChangeset for help on using the changeset viewer.