IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 1, 2010, 3:09:47 PM (16 years ago)
Author:
Paul Price
Message:

Merging branches/haf_branches/ipp.20100512/ into trunk: addtool development to ingest sources into separate dvo catalogues and dvodb merging. (Committed by PAP for HAF)

Location:
trunk
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ippScripts/scripts/minidvodb_merge.pl

    r28180 r28181  
    8787unless ($no_op) {
    8888    if (defined $mergedvodbReal) {
    89         {
     89        {
    9090            my $command  = "$addstar -resort";
    9191            $command .= " -D CAMERA $camera";
     
    101101            }
    102102            $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);  $dtime_resort = $dtime_addstar;
    103             # MJD of starting script
     103            # MJD of starting script
    104104            print "addstar -resort time $dtime_addstar\n";
    105105        }
     
    123123            print "relphot time $dtime_relphot\n";
    124124        }
    125        
    126         {
    127 
    128             my $mdcParser = PS::IPP::Metadata::Config->new;
    129            
    130 
    131             my $command = "$addtool -listminidvodbrun -state mergedsdfsad -minidvodb_group " . $minidvodb_group;
    132             $command .= " -dbname $dbname" if defined $dbname;
    133 
    134            
    135 
    136             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     125
     126        my $this_is_the_first;
     127        {
     128
     129            my $mdcParser = PS::IPP::Metadata::Config->new;
     130
     131            my $command = "$addtool -listminidvodbrun -state mergedsdfsad -minidvodb_group " . $minidvodb_group;
     132            $command .= " -dbname $dbname" if defined $dbname;
     133
     134            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    137135                    run(command => $command, verbose => $verbose);
    138             &my_die( "Unable to get list of minidvodbruns", $minidvodb_id, $PS_EXIT_SYS_ERROR) unless $success;
    139             my $this_is_the_first;
    140             if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
    141                 $this_is_the_first =1;
    142             } else {
    143                  my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     136            &my_die( "Unable to get list of minidvodbruns", $minidvodb_id, $PS_EXIT_SYS_ERROR) unless $success;
     137            if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
     138                $this_is_the_first =1;
     139            } else {
     140                my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    144141                    &my_die("Unable to parse metadata config", $minidvodb_id, $PS_EXIT_PROG_ERROR);
    145                 #this fails if there is nothing listed. I checked.
     142                #this fails if there is nothing listed. I checked.
    146143                my $components = parse_md_list($metadata) or
    147144                    &my_die("Unable to parse metadata list", $minidvodb_id, $PS_EXIT_PROG_ERROR);
    148145                my $comp = $$components[0];
    149            my  $minidvodb_name = $comp->{minidvodb_name};
    150        
     146                my  $minidvodb_name = $comp->{minidvodb_name};
     147
    151148                if (!defined($minidvodb_name)) {
    152149                    &my_die("Unable to parse minidvodb_name", $minidvodb_id, $PS_EXIT_PROG_ERROR);
    153150                } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk.
    154                  $this_is_the_first = 0;
    155             }
    156 
    157             my $merge_command;
    158             if ($this_is_the_first) {
    159                
    160                 $merge_command = "cp -rp $minidvodb $mergedvodb"
    161 
    162             } else {
    163 
    164                 $merge_command = "$dvomerge $minidvodb into $mergedvodb"
    165             }
    166 
    167 
    168 
    169             system ($merge_command);
    170 
    171             my ( $success2, $error_code2, $full_buf2, $stdout_buf2, $stderr_buf2 ) =
    172                 run(command => $merge_command, verbose => $verbose);
    173         unless ($success2) {
    174             $error_code2 = (($error_code2 >> 8) or $PS_EXIT_PROG_ERROR);
    175             &my_die("Unable to merge: $error_code", $mergedvodb, $error_code2);
    176         }
    177 
    178                    
    179             $dtime_merge = 86400.0*(DateTime->now->mjd - $mjd_relphot_start);   # MJD of starting script
     151                $this_is_the_first = 0;
     152            }
     153        }
     154
     155        {
     156            my $merge_command;
     157            if ($this_is_the_first) {
     158                $merge_command = "cp -rp $minidvodb $mergedvodb"
     159            } else {
     160                $merge_command = "$dvomerge $minidvodb into $mergedvodb"
     161            }
     162
     163            my $mjd_merge_start = DateTime->now->mjd;   # MJD of starting script
     164
     165            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     166                run(command => $merge_command, verbose => $verbose);
     167            unless ($success) {
     168                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     169                &my_die("Unable to merge: $error_code", $mergedvodb, $error_code);
     170            }
     171
     172            $dtime_merge = 86400.0*(DateTime->now->mjd - $mjd_merge_start);   # MJD of starting script
    180173            print "merge time $dtime_merge\n";
    181            
    182         }
    183        
    184 
    185         {
    186         my $command = "addtool -minidvodb_id $minidvodb_id";
    187         $command .= " -addminidvodbprocessed";
    188         $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
    189         $command .= " -minidvodb_group $minidvodb_group";
    190         $command .= " -dtime_relphot $dtime_relphot"  if defined $dtime_relphot;
    191         $command .= " -dtime_relphot $dtime_resort" if defined $dtime_resort;
    192         $command .= " -dtime_relphot $dtime_merge" if defined $dtime_merge;
    193         $command .= " -dbname $dbname" if defined $dbname;
    194     #print $command;
    195         system ($command);
    196 
    197         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    198             run(command => $command, verbose => $verbose);
    199         unless ($success) {
    200             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    201             &my_die("Unable to add to minidvodbprocessed: $error_code", $mergedvodb, $error_code);
    202         }
    203 
    204         }
     174        }
     175
     176
     177        {
     178            my $command = "addtool -minidvodb_id $minidvodb_id";
     179            $command .= " -addminidvodbprocessed";
     180            $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
     181            $command .= " -minidvodb_group $minidvodb_group";
     182            $command .= " -dtime_relphot $dtime_relphot"  if defined $dtime_relphot;
     183            $command .= " -dtime_relphot $dtime_resort" if defined $dtime_resort;
     184            $command .= " -dtime_relphot $dtime_merge" if defined $dtime_merge;
     185            $command .= " -dbname $dbname" if defined $dbname;
     186            #print $command;
     187
     188            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     189                run(command => $command, verbose => $verbose);
     190            unless ($success) {
     191                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     192                &my_die("Unable to add to minidvodbprocessed: $error_code", $mergedvodb, $error_code);
     193            }
     194        }
    205195
    206196    } else {
     
    217207{
    218208    my $msg = shift; # Warning message on die
    219     my $minidbvodb_id = shift; 
     209    my $minidbvodb_id = shift;
    220210    my $exit_code = shift; # Exit code to add
    221211
     
    223213
    224214if (defined $minidvodb_id ) {
    225    
     215
    226216    my $command = "addtool -minidvodb_id $minidvodb_id";
    227217    $command .= " -addminidvodbprocessed";
    228218        $command .= " -fault $exit_code";
    229         $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
    230         $command .= " -minidvodb_group $minidvodb_group";
     219        $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
     220        $command .= " -minidvodb_group $minidvodb_group";
    231221        $command .= " -dtime_relphot $dtime_relphot" if defined $dtime_relphot;
    232222        $command .= " -dtime_relphot $dtime_resort" if defined $dtime_resort;
    233223        $command .= " -dtime_relphot $dtime_merge" if defined $dtime_merge;
    234224        $command .= " -dbname $dbname" if defined $dbname;
    235    
    236    
     225
     226
    237227
    238228    #print $command;
Note: See TracChangeset for help on using the changeset viewer.