IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12636


Ignore:
Timestamp:
Mar 28, 2007, 9:53:03 AM (19 years ago)
Author:
Paul Price
Message:

Making script able to parse long long long lists of stuff to process.

File:
1 edited

Legend:

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

    r12020 r12636  
    3535
    3636# Phase 0 imfile processing
    37 my $list;
    3837{
    3938    my $command = "$regtool -pendingimfile -dbname $dbname"; # Command to run
     
    4140        run( command => $command, verbose => 1 );
    4241    die "Unable to get phase 0 imfile list: $error_code\n" if not $success;
    43     $list = parse_md_list( $mdcParser->parse( join( '', @$stdout_buf ) ) ) or
    44         die "Unable to parse output from regtool.\n";
    45 }
    4642
    47 foreach my $item (@$list) {
    48     my $exp_tag = $item->{exp_tag};
    49     my $class = $item->{class};
    50     my $class_id = $item->{class_id};
    51     my $uri = $item->{uri};
    52    
    53     my $command = "$register_imfile --exp_tag $exp_tag --class $class --class_id $class_id --uri $uri --dbname $dbname";
    54     $command .= " --workdir $workdir" if defined $workdir;
    55     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    56         run( command => $command, verbose => 1 );
    57     die "Unable to do phase 0 imfile processing on $exp_tag $class_id: $error_code\n" if not $success;
     43    my @whole = split /\n/, join( '', @$stdout_buf );
     44    my @single = ();
     45
     46    while ( scalar @whole > 0 ) {
     47        my $value = shift @whole;
     48        push @single, $value;
     49        if ($value =~ /^\s*END\s*$/) {
     50            push @single, "\n";
     51
     52            my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ) or
     53                die "Unable to parse output from regtool.\n";
     54
     55            foreach my $item (@$list) {
     56                my $exp_tag = $item->{exp_tag};
     57                my $class = $item->{class};
     58                my $class_id = $item->{class_id};
     59                my $uri = $item->{uri};
     60               
     61                my $command = "$register_imfile --exp_tag $exp_tag --class $class --class_id $class_id --uri $uri --dbname $dbname";
     62                $command .= " --workdir $workdir" if defined $workdir;
     63                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     64                    run( command => $command, verbose => 1 );
     65                die "Unable to do phase 0 imfile processing on $exp_tag $class_id: $error_code\n" if not $success;
     66            }
     67
     68
     69            @single = ();
     70
     71        }       
     72    }
    5873}
    5974
     
    6479        run( command => $command, verbose => 1 );
    6580    die "Unable to get phase 0 exposure list: $error_code\n" if not $success;
    66     $list = parse_md_list( $mdcParser->parse( join( '', @$stdout_buf ) ) ) or
    67         die "Unable to parse output from regtool.\n";
     81
     82    my @whole = split /\n/, join( '', @$stdout_buf );
     83    my @single = ();
     84
     85    while ( scalar @whole > 0 ) {
     86        my $value = shift @whole;
     87        push @single, $value;
     88        if ($value =~ /^\s*END\s*$/) {
     89            push @single, "\n";
     90
     91            my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ) or
     92                die "Unable to parse output from regtool.\n";
     93
     94            foreach my $item (@$list) {
     95                my $exp_tag = $item->{exp_tag};
     96               
     97                my $command = "$register_exp --exp_tag $exp_tag --dbname $dbname";
     98                $command .= " --workdir $workdir" if defined $workdir;
     99                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     100                    run( command => $command, verbose => 1 );
     101                die "Unable to do phase 0 exposure processing on $exp_tag: $error_code\n" if not $success;
     102            }
     103
     104            @single = ();
     105
     106        }       
     107    }
    68108}
    69109
    70 foreach my $item (@$list) {
    71     my $exp_tag = $item->{exp_tag};
    72    
    73     my $command = "$register_exp --exp_tag $exp_tag --dbname $dbname";
    74     $command .= " --workdir $workdir" if defined $workdir;
    75     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    76         run( command => $command, verbose => 1 );
    77     die "Unable to do phase 0 exposure processing on $exp_tag: $error_code\n" if not $success;
    78 }
    79110
    80111END {
Note: See TracChangeset for help on using the changeset viewer.