Changeset 214


Ignore:
Timestamp:
03/29/06 22:13:26 (18 years ago)
Author:
nanardon
Message:
  • add a way to execute a command after processing, file list is pipe to the process
Location:
trunk/soft/ObsData
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/soft/ObsData/ObsData.pm

    r211 r214  
    404404} 
    405405 
     406sub postprocessed { 
     407    my ($self) = @_; 
     408    my %datastype; 
     409    foreach my $entry (@{$self->{processed_lists}}) { 
     410        push(@{$datastype{$entry->{datatype}}}, $entry); 
     411    } 
     412 
     413    foreach my $datatype (keys %datastype) { 
     414        my $command = $self->getvalue($datatype, 'postexec'); 
     415        $self->logging(0, 'postexec for %s is %s', 
     416            $datatype, 
     417            $command ? "`$command'" : 'not set, skipping', 
     418        ); 
     419        if ($command) { 
     420            if (open(my $posthandle, "| $command")) { 
     421                foreach (@{$datastype{$datatype}}) { 
     422                    print $posthandle "$_->{destfile}\n" or do { 
     423                        $self->logging(4, "cannot write to postexec handle for `%s': %s", 
     424                            $datatype, 
     425                            $!, 
     426                        ); 
     427                        last; 
     428                    }; 
     429                } 
     430                my $exitstatus = close($posthandle); 
     431                $self->logging($exitstatus ? 0 : 4, 
     432                    "postexec for %s exit %s", 
     433                    $datatype, 
     434                    $exitstatus ? "correctly" : "with failure : " . ($! ? ($!) : "(??)"), 
     435                ); 
     436            } else { 
     437                $self->logging(4, "Cannot exec post `%s' for `%s'", 
     438                    $command, 
     439                    $datatype, 
     440                ); 
     441                next; 
     442            } 
     443        } 
     444    } 
     445} 
     446 
    4064471; 
    407448 
  • trunk/soft/ObsData/bin/obsdata

    r211 r214  
    132132 
    133133my $s = $obsdata->generated_reported(); 
    134  
    135  
     134$s = $obsdata->postprocessed(); 
    136135 
    137136=head1 AUTHOR 
  • trunk/soft/ObsData/testdata/obsdata-conftest

    r211 r214  
    1818dest=%s/dest%s 
    1919reportto=nanardon@nanardon.zarb.org 
     20postexec=cat > postexec.log 
    2021 
    2122[oxygene] 
Note: See TracChangeset for help on using the changeset viewer.