From 004f1dc09b243c2b009145c99247d2741a2668a7 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Sun, 25 Mar 2012 23:29:13 +0000 Subject: (generate_comment) split it out of perform_command() --- lib/Iurt/Process.pm | 39 ++++++++++++++++++++++----------------- 1 file 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 -- cgit v1.2.1