[Bio] / FortyEight / Mantis.pm Repository:
ViewVC logotype

Diff of /FortyEight/Mantis.pm

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

revision 1.2, Fri Oct 5 17:24:56 2007 UTC revision 1.3, Fri Feb 15 19:17:39 2008 UTC
# Line 5  Line 5 
5  use Data::Dumper;  use Data::Dumper;
6  use POSIX;  use POSIX;
7  use LWP::UserAgent;  use LWP::UserAgent;
8    use File::Basename;
9    
10  use base 'Class::Accessor';  use base 'Class::Accessor';
11  use DBI;  use DBI;
# Line 107  Line 108 
108               $project, $reporter, $handler, $text_id, $summary, $self->info->{bug_category});               $project, $reporter, $handler, $text_id, $summary, $self->info->{bug_category});
109      my $bug_id = $dbh->{mysql_insertid};      my $bug_id = $dbh->{mysql_insertid};
110    
111        {
112      my $b = $meta->get_metadata('mantis.bug');      my $b = $meta->get_metadata('mantis.bug');
113      if (ref($b))      if (ref($b))
114      {      {
# Line 117  Line 119 
119          $b = [$bug_id];          $b = [$bug_id];
120      }      }
121      $meta->set_metadata('mantis.bug', $b);      $meta->set_metadata('mantis.bug', $b);
122        }
123    
124      #      #
125      # custom field.      # custom field.
# Line 167  Line 170 
170          rmdir($tmp);          rmdir($tmp);
171      }      }
172    
173        #
174        # Insert a note for each error file.
175        #
176    
177        my @err_files = <$opts{job_dir}/rp.errors/*>;
178        @err_files = map { my @s = stat($_); [$_, @s] } @err_files;
179    
180        my @empty;
181        for my $err_file (sort { $b->[10] <=> $a->[10] } @err_files)
182        {
183            my $path = $err_file->[0];
184    
185            if ($err_file->[8] == 0)
186            {
187                push(@empty, $path);
188                next;
189            }
190    
191            eval {
192                my $txt = "Last ten lines of error file $path:\n";
193                $txt .= `ls -l $path`;
194                $txt .= "\n";
195                $txt .= `tail -10 $path`;
196    
197                insert_note($dbh, $bug_id, $reporter, $txt);
198            };
199            if ($@)
200            {
201                warn "Error inserting bug note about $path: $@\n";
202            }
203        }
204    
205        if (@empty)
206        {
207            my $txt = "Empty error files:\n" . join("\n", @empty), "\n";
208            insert_note($dbh, $bug_id, $reporter, $txt);
209        }
210    
211      my $bug_url = $self->info->{public_url} . "/view.php?id=$bug_id";      my $bug_url = $self->info->{public_url} . "/view.php?id=$bug_id";
212      return($bug_id, $bug_url);      return($bug_id, $bug_url);
213  }  }
214    
215    
216    sub insert_note
217    {
218        my($dbh, $bug_id, $reporter, $txt) = @_;
219    
220        $dbh->do(qq(INSERT INTO mantis_bugnote_text_table(note) VALUES (?)),
221                 undef, $txt);
222        my $tid = $dbh->{mysql_insertid};
223        $dbh->do(qq(INSERT INTO mantis_bugnote_table (bug_id, reporter_id, bugnote_text_id, view_state,  date_submitted, last_modified)
224                    VALUES (?, ?, ?, 10, NOW(), NOW())), undef, $bug_id, $reporter, $tid);
225    }
226    
227  sub check_for_reporter  sub check_for_reporter
228  {  {
229      my($self, $email) = @_;      my($self, $email) = @_;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3