/[cvs]/nfo/perl/libs/Data/Rap/Engine.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Rap/Engine.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by joko, Fri Feb 21 01:46:17 2003 UTC revision 1.7 by joko, Fri Mar 28 07:02:56 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## ----------------------------------------------------------------------  ## ----------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.7  2003/03/28 07:02:56  joko
6    ##  modified structure around '$wrapper_program'
7    ##
8    ##  Revision 1.6  2003/03/27 15:31:05  joko
9    ##  fixes to modules regarding new namespace(s) below Data::Mungle::*
10    ##
11    ##  Revision 1.5  2003/03/27 15:03:03  joko
12    ##  enhanced 'sub run_executable'
13    ##
14    ##  Revision 1.4  2003/02/22 16:51:21  joko
15    ##  + enhanced run_executable
16    ##  modified logging output
17    ##
18  ##  Revision 1.3  2003/02/21 01:46:17  joko  ##  Revision 1.3  2003/02/21 01:46:17  joko
19  ##  renamed core function  ##  renamed core function
20  ##  ##
# Line 27  use Hash::Merge qw( merge ); Line 40  use Hash::Merge qw( merge );
40  use Iterate;  use Iterate;
41    
42  use shortcuts qw( run_cmd );  use shortcuts qw( run_cmd );
43  use Data::Code::Ref qw( ref_slot );  use Data::Mungle::Code::Ref qw( ref_slot );
44  use Data::Transform::Deep qw( expand );  use Data::Mungle::Transform::Deep qw( expand );
45    
46    
47  sub performTarget {  sub performTarget {
# Line 41  sub perform_target { Line 54  sub perform_target {
54    my $self = shift;    my $self = shift;
55    my $targetname = shift;    my $targetname = shift;
56    
57    $self->log("Performing Target '$targetname'.", 'notice');    my $header = ("- " x 12) . "   " . $targetname . "   " . ("- " x 6);
58      
59      #$self->log("- " x 35, 'notice');
60      #$self->log("Performing Target '$targetname'.", 'notice');
61    
62      $self->log($header, 'notice');
63    
64    #exit;    #exit;
65    
# Line 102  sub perform_command { Line 120  sub perform_command {
120    my $command = shift;    my $command = shift;
121    
122    if (!$command) {    if (!$command) {
123      $self->log("Command was empty!", 'warning');      $self->log("Command was empty!", 'debug');
124      return;      return;
125    }    }
126    
# Line 287  sub run_executable { Line 305  sub run_executable {
305      my $program = $opts->{executable};      my $program = $opts->{executable};
306      delete $opts->{executable};      delete $opts->{executable};
307    
308        # determine execution method
309        my $wrapper_program = '';
310        
311        # check if program is a namespace-string (contains '::') - use 'do' in this case!
312        if ($program =~ /::/) {
313          #$wrapper_program = 'rap.pl';
314          $wrapper_program = $0;
315        }
316    
317        # prepare arguments
318      my @buf;      my @buf;
319      foreach (keys %$opts) {      foreach (keys %$opts) {
320        my $value = $opts->{$_};        my $value = $opts->{$_};
321          if (m/^_/) {
322            if ($_ eq '_switches') {
323              my @switches = split(/,\s|,/, $value);
324              foreach my $switch (@switches) {
325                push @buf, '--' . $switch;
326              }
327            }
328            next;
329          }
330          
331        if ($value =~ /\s/) {        if ($value =~ /\s/) {
332          $value = "\"$value\"";          $value = "\"$value\"";
333        }        }
334        push @buf, "--$_=$value";        push @buf, "--$_=$value";
335      }      }
336      
337      my $cmd = $program . ' ' . join(' ', @buf);      # build {program} & {arguments}  
338        my $cmd = ($wrapper_program ? $wrapper_program . ' ' : '') . $program . ' ' . join(' ', @buf);
339            
340      # trace      # trace
341        #print "command: $cmd", "\n";        #print "command: $cmd", "\n";
# Line 309  sub run_executable { Line 348  sub run_executable {
348        $ENV{PERL5LIB} = $INC[0];        $ENV{PERL5LIB} = $INC[0];
349                
350        #print Dumper(%ENV);        #print Dumper(%ENV);
351        run_cmd($cmd);        
352          #print "command: '$cmd'", "\n";
353    
354          # V1 - basic
355          #run_cmd($cmd);
356    
357          # V1.b - enhanced: variable local method
358          my $evalstr = "run_cmd('$cmd', 'Some task...', { async => 1 });";
359          eval($evalstr);
360          #my $res = do "$cmd";
361          #print $res, "\n" if $res;
362    
363          #$self->log("run_executable: $evalstr", 'info');
364          $self->raiseException("run_executable: $evalstr\n$@") if $@;
365    
366        # V2: via IPC::Run        # V2: via IPC::Run
367        # ....  (TODO)        # ....  (TODO)
368              
369            
370    }    }
371        

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.7

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed