/[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.2 by joko, Thu Feb 20 19:46:33 2003 UTC revision 1.5 by joko, Thu Mar 27 15:03:03 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## ----------------------------------------------------------------------  ## ----------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.5  2003/03/27 15:03:03  joko
6    ##  enhanced 'sub run_executable'
7    ##
8    ##  Revision 1.4  2003/02/22 16:51:21  joko
9    ##  + enhanced run_executable
10    ##  modified logging output
11    ##
12    ##  Revision 1.3  2003/02/21 01:46:17  joko
13    ##  renamed core function
14    ##
15  ##  Revision 1.2  2003/02/20 19:46:33  joko  ##  Revision 1.2  2003/02/20 19:46:33  joko
16  ##  renamed and revamped some of modules  ##  renamed and revamped some of modules
17  ##  renamed methods  ##  renamed methods
# Line 38  sub perform_target { Line 48  sub perform_target {
48    my $self = shift;    my $self = shift;
49    my $targetname = shift;    my $targetname = shift;
50    
51    $self->log("Performing Target '$targetname'.", 'notice');    my $header = ("- " x 12) . "   " . $targetname . "   " . ("- " x 6);
52      
53      #$self->log("- " x 35, 'notice');
54      #$self->log("Performing Target '$targetname'.", 'notice');
55    
56      $self->log($header, 'notice');
57    
58    #exit;    #exit;
59    
# Line 99  sub perform_command { Line 114  sub perform_command {
114    my $command = shift;    my $command = shift;
115    
116    if (!$command) {    if (!$command) {
117      $self->log("Command was empty!", 'warning');      $self->log("Command was empty!", 'debug');
118      return;      return;
119    }    }
120    
# Line 155  sub merge_properties { Line 170  sub merge_properties {
170      #print "DATA NEE! - MERGE!", "\n";      #print "DATA NEE! - MERGE!", "\n";
171      #print Dumper($data_new);      #print Dumper($data_new);
172      #exit;      #exit;
173      #hash2object($self, $data_new);      #merge_to($self, $data_new);
174      $self->set_property( { name => $name, value => $data_new } );      $self->set_property( { name => $name, value => $data_new } );
175            
176    } else {    } else {
# Line 284  sub run_executable { Line 299  sub run_executable {
299      my $program = $opts->{executable};      my $program = $opts->{executable};
300      delete $opts->{executable};      delete $opts->{executable};
301    
302        # determine execution method
303        my $method = 'run_cmd';
304        my $wrapper_program = '';
305        
306        # check if program is a namespace-string (contains '::') - use 'do' in this case!
307        if ($program =~ /::/) {
308        #if ($program =~ s/::/\\/g) {
309          #$program = '.\\' . $program;
310          #$method = 'require';
311          #do "$program";
312          #return;
313          #$method = 'rap.';
314          
315          $wrapper_program = 'rap.pl';
316          
317        }
318    
319        # prepare arguments
320      my @buf;      my @buf;
321      foreach (keys %$opts) {      foreach (keys %$opts) {
322        my $value = $opts->{$_};        my $value = $opts->{$_};
323          if (m/^_/) {
324            if ($_ eq '_switches') {
325              my @switches = split(/,\s|,/, $value);
326              foreach my $switch (@switches) {
327                push @buf, '--' . $switch;
328              }
329            }
330            next;
331          }
332          
333        if ($value =~ /\s/) {        if ($value =~ /\s/) {
334          $value = "\"$value\"";          $value = "\"$value\"";
335        }        }
336        push @buf, "--$_=$value";        push @buf, "--$_=$value";
337      }      }
338      
339      my $cmd = $program . ' ' . join(' ', @buf);      # build {program} & {arguments}  
340        my $cmd = join(' ', $wrapper_program, $program) . ' ' . join(' ', @buf);
341            
342      # trace      # trace
343        #print "command: $cmd", "\n";        #print "command: $cmd", "\n";
# Line 306  sub run_executable { Line 350  sub run_executable {
350        $ENV{PERL5LIB} = $INC[0];        $ENV{PERL5LIB} = $INC[0];
351                
352        #print Dumper(%ENV);        #print Dumper(%ENV);
353        run_cmd($cmd);        
354          print "command: '$cmd'", "\n";
355    
356          # V1 - basic
357          #run_cmd($cmd);
358    
359          # V1.b - enhanced: variable local method
360          my $evalstr = "$method('$cmd');";
361          eval($evalstr);
362          #my $res = do "$cmd";
363          #print $res, "\n" if $res;
364    
365          #$self->log("run_executable: $evalstr", 'info');
366          $self->raiseException("run_executable: $evalstr\n$@") if $@;
367    
368        # V2: via IPC::Run        # V2: via IPC::Run
369        # ....  (TODO)        # ....  (TODO)
370            

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

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