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 |
19 |
|
## renamed core function |
20 |
|
## |
21 |
## Revision 1.2 2003/02/20 19:46:33 joko |
## Revision 1.2 2003/02/20 19:46:33 joko |
22 |
## renamed and revamped some of modules |
## renamed and revamped some of modules |
23 |
## renamed methods |
## renamed methods |
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 { |
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 |
|
|
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 |
|
|
176 |
#print "DATA NEE! - MERGE!", "\n"; |
#print "DATA NEE! - MERGE!", "\n"; |
177 |
#print Dumper($data_new); |
#print Dumper($data_new); |
178 |
#exit; |
#exit; |
179 |
#hash2object($self, $data_new); |
#merge_to($self, $data_new); |
180 |
$self->set_property( { name => $name, value => $data_new } ); |
$self->set_property( { name => $name, value => $data_new } ); |
181 |
|
|
182 |
} else { |
} else { |
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"; |
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 |
|
|