diff options
author | Thierry Vignaud <tv@mageia.org> | 2012-03-25 23:29:13 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2012-03-25 23:29:13 +0000 |
commit | 004f1dc09b243c2b009145c99247d2741a2668a7 (patch) | |
tree | 79eee8081ff971752d7438dc8b2299f0cee14ba1 | |
parent | a61311b48af6dcae2165e230ce91bf77706b6f85 (diff) | |
download | iurt-004f1dc09b243c2b009145c99247d2741a2668a7.tar iurt-004f1dc09b243c2b009145c99247d2741a2668a7.tar.gz iurt-004f1dc09b243c2b009145c99247d2741a2668a7.tar.bz2 iurt-004f1dc09b243c2b009145c99247d2741a2668a7.tar.xz iurt-004f1dc09b243c2b009145c99247d2741a2668a7.zip |
(generate_comment) split it out of perform_command()
-rw-r--r-- | lib/Iurt/Process.pm | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/Iurt/Process.pm b/lib/Iurt/Process.pm index 294c3e6..d1292ca 100644 --- a/lib/Iurt/Process.pm +++ b/lib/Iurt/Process.pm @@ -184,6 +184,27 @@ sub handle_wait_regexp { $inc; } +sub generate_comment { + my ($run, $config, $output, $command, $comment, $pipe, $kill, %opt) = @_; + if ($kill && $opt{type} ne 'shell') { + $comment = "Command killed after $opt{timeout}s: $command\n"; + my ($cmd_to_kill) = $command =~ /sudo(?: chroot \S+)? (.*)/; + clean_process($cmd_to_kill); + } elsif ($pipe) { + $comment = "Command received SIGPIPE: $command\n"; + sendmail($config->{admin}, '' , + "$opt{hash} on $run->{my_arch} for $run->{media}: broken pipe", + "$comment\n$output", "Iurt the build bot <$config->{admin}>", + $opt{debug_mail}, $config); + } else { + if ($opt{type} eq 'shell') { + $comment = "Command failed: $command\n"; + } else { + $comment = "Command failed: $opt{type}\n"; + } + } +} + =head2 perform_command($command, $run, $config, $cache, %opt) Run a command and check various running parameters such as log size, timeout... @@ -292,23 +313,7 @@ sub perform_command { $call_ret == -2 and return 0; } - if ($kill && $opt{type} ne 'shell') { - $comment = "Command killed after $opt{timeout}s: $command\n"; - my ($cmd_to_kill) = $command =~ /sudo(?: chroot \S+)? (.*)/; - clean_process($cmd_to_kill); - } elsif ($pipe) { - $comment = "Command received SIGPIPE: $command\n"; - sendmail($config->{admin}, '' , - "$opt{hash} on $run->{my_arch} for $run->{media}: broken pipe", - "$comment\n$output", "Iurt the build bot <$config->{admin}>", - $opt{debug_mail}, $config); - } else { - if ($opt{type} eq 'shell') { - $comment = "Command failed: $command\n"; - } else { - $comment = "Command failed: $opt{type}\n"; - } - } + $comment = generate_comment($run, $config, $output, $command, $comment, $pipe, $kill, %opt); # Maybe this has to be put before all the commands altering the # $output var |