Exemplo n.º 1
0
 def end_step(self, lineno, timestamp=None, result_code=None):
     """Fill in the current step's summary and update the state to show the current step has ended."""
     self.state = self.STATES['step_finished']
     step_errors = self.sub_parser.get_artifact()
     step_error_count = len(step_errors)
     if step_error_count > settings.PARSER_MAX_STEP_ERROR_LINES:
         step_errors = step_errors[:settings.PARSER_MAX_STEP_ERROR_LINES]
         self.artifact["errors_truncated"] = True
     self.current_step.update({
         "finished":
         timestamp,
         "finished_linenumber":
         lineno,
         # Whilst the result code is present on both the start and end buildbot-style step
         # markers, for Taskcluster logs the start marker line lies about the result, since
         # the log output is unbuffered, so Taskcluster does not know the real result at
         # that point. As such, we only set the result when ending a step.
         "result":
         RESULT_DICT.get(result_code, "unknown"),
         "errors":
         step_errors,
         "error_count":
         step_error_count
     })
     self.current_step["duration"] = self.calculate_duration()
     # Append errors from current step to "all_errors" field
     self.artifact["all_errors"].extend(step_errors)
     # reset the sub_parser for the next step
     self.sub_parser.clear()
Exemplo n.º 2
0
 def end_step(self, lineno, timestamp=None, result_code=None):
     """Fill in the current step's summary and update the state to show the current step has ended."""
     self.state = self.STATES["step_finished"]
     step_errors = self.sub_parser.get_artifact()
     step_error_count = len(step_errors)
     if step_error_count > settings.PARSER_MAX_STEP_ERROR_LINES:
         step_errors = step_errors[: settings.PARSER_MAX_STEP_ERROR_LINES]
         self.artifact["errors_truncated"] = True
     self.current_step.update(
         {
             "finished": timestamp,
             "finished_linenumber": lineno,
             # Whilst the result code is present on both the start and end buildbot-style step
             # markers, for Taskcluster logs the start marker line lies about the result, since
             # the log output is unbuffered, so Taskcluster does not know the real result at
             # that point. As such, we only set the result when ending a step.
             "result": RESULT_DICT.get(result_code, "unknown"),
             "errors": step_errors,
             "error_count": step_error_count,
         }
     )
     self.current_step["duration"] = self.calculate_duration()
     # Append errors from current step to "all_errors" field
     self.artifact["all_errors"].extend(step_errors)
     # reset the sub_parser for the next step
     self.sub_parser.clear()
Exemplo n.º 3
0
    def parse_line(self, line, lineno):
        """Parse a single non-header line of the log"""
        # Check if we're waiting for a step start line.
        if not self.state == self.ST_STARTED:
            match = RE_STEP_START.match(line)
            if match:
                self.state = self.ST_STARTED
                self.stepnum += 1
                self.steps.append({
                    "name": match.group('name'),
                    "started": match.group('timestamp'),
                    "started_linenumber": lineno,
                    "order": self.stepnum,
                    "errors": [],
                })
            return

        # Check if it's the end of a step.
        match = RE_STEP_FINISH.match(line)
        if match:
            self.state = self.ST_FINISHED
            step_errors = self.sub_parser.get_artifact()
            step_error_count = len(step_errors)
            if step_error_count > settings.PARSER_MAX_STEP_ERROR_LINES:
                step_errors = step_errors[:settings.
                                          PARSER_MAX_STEP_ERROR_LINES]
                self.artifact["errors_truncated"] = True
            self.current_step.update({
                "finished":
                match.group('timestamp'),
                "finished_linenumber":
                lineno,
                "result":
                RESULT_DICT.get(int(match.group('result')), "unknown"),
                "errors":
                step_errors,
                "error_count":
                step_error_count
            })
            self.set_duration()
            # Append errors from current step to "all_errors" field
            self.artifact["all_errors"].extend(step_errors)
            # reset the sub_parser for the next step
            self.sub_parser.clear()
            return

        # Otherwise just parse the line, since we're in the middle of a step.
        if self.check_errors:
            self.sub_parser.parse_line(line, lineno)
Exemplo n.º 4
0
    def parse_line(self, line, lineno):
        """Parse a single non-header line of the log"""
        # Check if we're waiting for a step start line.
        if not self.state == self.ST_STARTED:
            match = self.RE_STEP_START.match(line)
            if match:
                self.state = self.ST_STARTED
                self.stepnum += 1
                self.steps.append({
                    "name": match.group('name'),
                    "started": match.group('timestamp'),
                    "started_linenumber": lineno,
                    "order": self.stepnum,
                    "errors": [],
                })
            return

        # Check if it's the end of a step.
        match = self.RE_STEP_FINISH.match(line)
        if match:
            self.state = self.ST_FINISHED
            step_errors = self.sub_parser.get_artifact()
            step_error_count = len(step_errors)
            if step_error_count > settings.PARSER_MAX_STEP_ERROR_LINES:
                step_errors = step_errors[:settings.PARSER_MAX_STEP_ERROR_LINES]
                self.artifact["errors_truncated"] = True
            self.current_step.update({
                "finished": match.group('timestamp'),
                "finished_linenumber": lineno,
                "result": RESULT_DICT.get(int(match.group('result')), "unknown"),
                "errors": step_errors,
                "error_count": step_error_count
            })
            self.set_duration()
            # Append errors from current step to "all_errors" field
            self.artifact["all_errors"].extend(step_errors)
            # reset the sub_parser for the next step
            self.sub_parser.clear()
            return

        # Otherwise just parse the line, since we're in the middle of a step.
        if self.check_errors:
            self.sub_parser.parse_line(line, lineno)