uh_parser/RaptorError.pm
changeset 209 ba90e30c0f3c
parent 185 b76adfbc6648
child 211 c01247054e72
equal deleted inserted replaced
208:2101b329ee80 209:ba90e30c0f3c
    35 $buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error';
    35 $buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error';
    36 $buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error';
    36 $buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error';
    37 
    37 
    38 my $filename = '';
    38 my $filename = '';
    39 
    39 
       
    40 my $raptor_error_info = {};
       
    41 
    40 my $characters = '';
    42 my $characters = '';
    41 
    43 
    42 my $CATEGORY_RAPTORERROR = 'raptor_error';
    44 my $CATEGORY_RAPTORERROR = 'raptor_error';
    43 my $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION = 'cannot_process_schema_version';
    45 my $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION = 'cannot_process_schema_version';
    44 my $CATEGORY_RAPTORERROR_NOBLDINFFOUND = 'no_bld_inf_found';
    46 my $CATEGORY_RAPTORERROR_NOBLDINFFOUND = 'no_bld_inf_found';
   133 }
   135 }
   134 
   136 
   135 sub on_start_buildlog
   137 sub on_start_buildlog
   136 {
   138 {
   137 	RaptorCommon::init();
   139 	RaptorCommon::init();
   138 	
       
   139 	$filename = "$::raptorbitsdir/raptor_error.txt";
       
   140 	if (!-f$filename)
       
   141 	{
       
   142 		print "Writing errors file $filename\n";
       
   143 		open(FILE, ">$filename");
       
   144 		close(FILE);
       
   145 	}
       
   146 }
   140 }
   147 
   141 
   148 sub on_start_buildlog_error
   142 sub on_start_buildlog_error
   149 {
   143 {
       
   144   my ($el) = @_;
       
   145 	
       
   146 	#print "on_start_buildlog_error\n";
       
   147 	
       
   148 	$raptor_error_info = {};
       
   149 	
       
   150 	my $attributes = $el->{Attributes};
       
   151 	for (keys %{$attributes})
       
   152 	{
       
   153 		$raptor_error_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'};
       
   154 		#print "$_ -> $attributes->{$_}->{'Value'}\n";
       
   155 	}
   150 }
   156 }
   151 
   157 
   152 sub on_chars_buildlog_error
   158 sub on_chars_buildlog_error
   153 {
   159 {
   154 	my ($ch) = @_;
   160 	my ($ch) = @_;
   161 }
   167 }
   162 
   168 
   163 sub on_end_buildlog_error
   169 sub on_end_buildlog_error
   164 {
   170 {
   165 	#print "on_end_buildlog_error\n";
   171 	#print "on_end_buildlog_error\n";
       
   172 	
       
   173 	my $package = '';
       
   174 	if ($raptor_error_info->{bldinf})
       
   175 	{
       
   176     $::allbldinfs->{$raptor_error_info->{bldinf}} = 1;
       
   177     
       
   178     # normalize bldinf path
       
   179 		$raptor_error_info->{bldinf} = lc($raptor_error_info->{bldinf});
       
   180 		$raptor_error_info->{bldinf} =~ s,^[A-Za-z]:,,;
       
   181 		$raptor_error_info->{bldinf} =~ s,[\\],/,g;
       
   182 		
       
   183 		if ($raptor_error_info->{bldinf} =~ m,/((os|mw|app|tools|ostools|adaptation)/[^/]*),)
       
   184 		{
       
   185 			$package = $1;
       
   186 			$package =~ s,/,_,;
       
   187 		}
       
   188 		else
       
   189 		{
       
   190 			print "WARNING: can't understand bldinf attribute of raptor error: $raptor_error_info->{bldinf}. Won't associate to package.\n";
       
   191 		}
       
   192   }
   166 	
   193 	
   167 	$characters =~ s,^[\r\n]*,,;
   194 	$characters =~ s,^[\r\n]*,,;
   168 	$characters =~ s,[\r\n]*$,,;
   195 	$characters =~ s,[\r\n]*$,,;
   169 	
   196 	
   170 	if ($characters =~ m,[^\s^\r^\n],)
   197 	if ($characters =~ m,[^\s^\r^\n],)
   171 	{	
   198 	{
   172 		my $dumped = process($characters, $::current_log_file, '', '', '', '', "raptor_error.txt");
   199     my $bldinf_field = '';
       
   200     if ($package)
       
   201 		{
       
   202 			$filename = "$::raptorbitsdir/$package.txt";
       
   203 			$bldinf_field = $raptor_error_info->{bldinf};
       
   204 		}
       
   205 		else
       
   206 		{
       
   207 		  $filename = "$::raptorbitsdir/raptor_error.txt";
       
   208 		}
       
   209 		
       
   210 		if (!-f$filename)
       
   211 		{
       
   212 			print "Writing file $filename\n";
       
   213 			open(FILE, ">$filename");
       
   214 			close(FILE);
       
   215 		}
       
   216 		
       
   217 		my $dumped = process($characters, $::current_log_file, $bldinf_field, '', '', '', "$package.txt");
   173 		
   218 		
   174 		if ($dumped)
   219 		if ($dumped)
   175 		{
   220 		{
   176 			open(FILE, ">>$filename");
   221 			open(FILE, ">>$filename");
   177 			print FILE "---failure_item_$::failure_item_number\---\n";
   222 			print FILE "---failure_item_$::failure_item_number\---\n";