IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2009, 1:44:40 PM (17 years ago)
Author:
bills
Message:

adapt to the presence of the dbversion structure in the dbinfo files

File:
1 edited

Legend:

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

    r24894 r25940  
    136136    $command .= " -dbname $dbname" if defined $dbname;
    137137
    138     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    139         run(command => $command, verbose => $verbose);
    140     &my_die( "Unable to update fileset $fileset_id to\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) unless $success;
     138    unless ($no_update) {
     139        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     140            run(command => $command, verbose => $verbose);
     141        &my_die( "Unable to update fileset $fileset_id to\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) unless $success;
     142    } else {
     143        print STDERR "skipping $command\n";
     144    }
    141145
    142146} elsif ($component eq "dbinfo") {
     
    164168    # we are very strict about the format of the file
    165169    #
    166     # First comes the data for the Run
    167     # Next is the data for each component
     170    # First comes the dbversion metadata
     171    # Next comes the data for the Run
     172    # Next is the data for each component and other associated tables
    168173    # The component_id (class_id, skycell_id) must come before any of the paths that we edit
    169174
    170     # The first line tells us the run type. From this we get the stage
    171     #
    172     my $line = $lines[0];
    173     my ($runType, $multi) = split " ", $line;
    174     &my_die( "unexpected first line found in $filename: $line\n", $file_id, $PS_EXIT_UNKNOWN_ERROR)
    175         if !$runType or ($multi ne 'MULTI');
     175    my $runType = findRunType(\@lines);
    176176
    177177    my $stage;
     
    215215        $component_dir = $components->{$current_component};
    216216    }
    217     foreach $line (@lines) {
     217    foreach my $line (@lines) {
    218218        my $out_line = $line;
    219219
     
    492492    return $new_path;
    493493}
     494sub findRunType {
     495    my $lines = shift;
     496    my $runType;
     497    my ($firstWord, $multi) = split " ", $lines->[0];
     498    &my_die( "unexpected first line found in $filename: $lines->[0]\n",
     499                $file_id, $PS_EXIT_UNKNOWN_ERROR) if ($firstWord ne 'dbversion') or ($multi ne 'MULTI');
     500
     501    my $dbversionDone = 0;
     502    foreach my $line (@$lines) {
     503        # skip blank lines
     504        next if !$line or $line eq "\n";
     505
     506        ($firstWord, $multi) = split " ", $line;
     507        if ($dbversionDone) {
     508            # The first non blank line after the dbversion tells us the run type.
     509            # From this we get the stage
     510            &my_die( "unexpected line found in $filename: $line\n",
     511                $file_id, $PS_EXIT_UNKNOWN_ERROR) if !$firstWord or !$multi or ($multi ne 'MULTI');
     512
     513            $runType = $firstWord;
     514            last;
     515        } else {
     516            if ($firstWord and $firstWord eq 'END') {
     517                # we're past the dbversion file now
     518                $dbversionDone = 1;
     519            }
     520        }
     521    }
     522    &my_die( "failed to determine run type from $filename",
     523                $file_id, $PS_EXIT_UNKNOWN_ERROR) if !$runType;
     524
     525    return $runType;
     526}
    494527
    495528sub my_die
Note: See TracChangeset for help on using the changeset viewer.