Query for TextLogErrorMatches identical to matches of the given TextLogError.
1148
def precise_matcher(text_log_error):
    """"""
    failure_line = text_log_error.metadata.failure_line
    logger.debug("Looking for test match in failure %d", failure_line.id)

    if failure_line.action != "test_result" or failure_line.message is None:
        return

    f = {
        'text_log_error___metadata__failure_line__action': 'test_result',
        'text_log_error___metadata__failure_line__test': failure_line.test,
        'text_log_error___metadata__failure_line__subtest': failure_line.subtest,
        'text_log_error___metadata__failure_line__status': failure_line.status,
        'text_log_error___metadata__failure_line__expected': failure_line.expected,
        'text_log_error___metadata__failure_line__message': failure_line.message
    }
    qwargs = (
        Q(text_log_error___metadata__best_classification=None)
        & (Q(text_log_error___metadata__best_is_verified=True)
           | Q(text_log_error__step__job=text_log_error.step.job))
    )
    qs = (TextLogErrorMatch.objects.filter(**f)
                                   .exclude(qwargs)
                                   .order_by('-score', '-classified_failure'))

    if not qs:
        return

    # chunk through the QuerySet because it could potentially be very large
    # time bound each call to the scoring function to avoid job timeouts
    # returns an iterable of (score, classified_failure_id) tuples
    chunks = chunked_qs_reverse(qs, chunk_size=20000)
    return chain.from_iterable(time_boxed(score_matches, chunks, time_budget=500))
1094254
def _match_setters(self, query):
        
        q = query.decode('utf-8')
        for name, parser, response, error_response in self._setters:
            try:
                value = parser(q)
                logger.debug('Found response in setter of %s' % name)
            except ValueError:
                continue

            try:
                self._properties[name].set_value(value)
                return response
            except ValueError:
                if isinstance(error_response, bytes):
                    return error_response
                return self.error_response('command_error')

        return None
472830
def error (logname, msg, *args, **kwargs):
    
    log = logging.getLogger(logname)
    if log.isEnabledFor(logging.ERROR):
        _log(log.error, msg, args, **kwargs)
1032599
def get_error_message(response_content):
    
    apache_regex = re.compile('.*<u>(.*)</u></p><p>.*')
    match = apache_regex.search(response_content)
    if match:
        error_message = match.group(1)
    else:
        local_regex = re.compile('.*<title>(.*)</title>.*')
        match = local_regex.search(response_content)
        if match:
            error_message = match.group(1)
        else:
            error_message = response_content
    return error_message
615260
def error(text = "")
      e = /ERROR\s(\d+)\s::\s(.*)/.match(text) || {}
      name = (e[2] || "UnknownError").titleize
      code = e[1] || -1
      error_class = name.gsub(/\s/, "")

      if error_class == "NothingFound"
        []
      else
        begin
          raise Semrush::Exception.const_get(error_class).new(self, "#{name} (#{code})")
        rescue
          raise Semrush::Exception::Base.new(self, "#{name} (#{code}) *** error_class=#{error_class} not implemented ***")
        end
      end
    end
1165976
def log_error(self, error, message, detail=None, strip=4):
        ""
        if message:
            msg = message + ": " + error
        else:
            msg = error

        tb = traceback.format_stack()
        if sys.version_info >= (3, 0):
            tb = tb[:-strip]
        else:
            tb = tb[strip:]

        self.errors.append({
            'message': msg,
            'traceback': tb,
            'detail': detail
        })
178061
def check_no_proxy_errors(self, **kwargs):
        
        data = self._es.search(body={
            "size": max_query_results,
            "query": {
                "filtered": {
                    "query": {
                        "match_all": {}
                    },
                    "filter": {
                        "term": {
                            "level": "error"
                        }
                    }
                }
            }
        })
#        if self.debug:
#            print(data)
        return GremlinTestResult(data["hits"]["total"] == 0, data)
128852
def text_log_errors(self, request, project, pk=None):
        
        try:
            job = Job.objects.get(repository__name=project,
                                  id=pk)
        except Job.DoesNotExist:
            return Response("No job with id: {0}".format(pk),
                            status=HTTP_404_NOT_FOUND)
        textlog_errors = (TextLogError.objects
                          .filter(step__job=job)
                          .select_related("_metadata",
                                          "_metadata__failure_line")
                          .prefetch_related("classified_failures", "matches")
                          .order_by('id'))
        return Response(serializers.TextLogErrorSerializer(textlog_errors,
                                                           many=True,
                                                           read_only=True).data)
789305
def default_match_error_handler(exc):
    
    if isinstance(exc, NotFound):
        return http.NotFound()
    elif isinstance(exc, MethodNotAllowed):
        return http.MethodNotAllowed()
    elif isinstance(exc, RequestRedirect):
        return redirect(exc.new_url)
    else:
        raise exc
326182
public List<RuleMatch> check(AnnotatedText annotatedText, boolean tokenizeText, ParagraphHandling paraMode, RuleMatchListener listener) throws IOException {
    return check(annotatedText, tokenizeText, paraMode, listener, Mode.ALL);
  }
1034357
def error(self, text):
		
		self.logger.error("{}{}".format(self.message_prefix, text))
718213
def regexp_error_msg(pattern):
    
    try:
        re.compile(pattern)
    except re.error as e:
        return str(e)
    return None
302058
def crash_signature_matcher(text_log_error):
    
    failure_line = text_log_error.metadata.failure_line

    if (failure_line.action != "crash" or
        failure_line.signature is None or
        failure_line.signature == "None"):
        return

    f = {
        'text_log_error___metadata__failure_line__action': 'crash',
        'text_log_error___metadata__failure_line__signature': failure_line.signature,
    }
    qwargs = (
        Q(text_log_error___metadata__best_classification=None)
        & (Q(text_log_error___metadata__best_is_verified=True)
           | Q(text_log_error__step__job=text_log_error.step.job))
    )
    qs = (TextLogErrorMatch.objects.filter(**f)
                                   .exclude(qwargs)
                                   .select_related('text_log_error', 'text_log_error___metadata')
                                   .order_by('-score', '-classified_failure'))

    size = 20000
    time_budget = 500

    # See if we can get any matches when filtering by the same test
    first_attempt = qs.filter(text_log_error___metadata__failure_line__test=failure_line.test)
    chunks = chunked_qs_reverse(first_attempt, chunk_size=size)
    scored_matches = chain.from_iterable(time_boxed(score_matches, chunks, time_budget))
    if scored_matches:
        return scored_matches

    # try again without filtering to the test but applying a .8 score multiplyer
    chunks = chunked_qs_reverse(qs, chunk_size=size)
    scored_matches = chain.from_iterable(time_boxed(
        score_matches,
        chunks,
        time_budget,
        score_multiplier=(8, 10),
    ))
    return scored_matches
328523
def error_from_exc(nsdk, tracer_h, e_val=None, e_ty=None):
    """"""

    if not tracer_h:
        return

    if e_ty is None and e_val is None:
        e_ty, e_val = sys.exc_info()[:2]
    if e_ty is None and e_val is not None:
        e_ty = type(e_val)
    nsdk.tracer_error(tracer_h, getfullname(e_ty), str(e_val))
132313
def ismatch(text, pattern):
    """"""

    if hasattr(pattern, 'search'):
        return pattern.search(text) is not None
    else:
        return pattern in text if Config.options.case_sensitive \
            else pattern.lower() in text.lower()
293868
def _parse(self, msg_dict):
        '''
        
        '''
        error_present = False
        # log.debug('Matching the message:')
        # log.debug(msg_dict)
        for message in self.compiled_messages:
            # log.debug('Matching using:')
            # log.debug(message)
            match_on = message['match_on']
            if match_on not in msg_dict:
                # log.debug('%s is not a valid key in the partially parsed dict', match_on)
                continue
            if message['tag'] != msg_dict[match_on]:
                continue
            if '__python_fun__' in message:
                return {
                    'model': message['model'],
                    'error': message['error'],
                    '__python_fun__': message['__python_fun__']
                }
            error_present = True
            match = message['line'].search(msg_dict['message'])
            if not match:
                continue
            positions = message.get('positions', {})
            values = message.get('values')
            ret = {
                'model': message['model'],
                'mapping': message['mapping'],
                'replace': message['replace'],
                'error': message['error']
            }
            for key in values.keys():
                # Check if the value needs to be replaced
                if key in message['replace']:
                    result = napalm_logs.utils.cast(match.group(positions.get(key)), message['replace'][key])
                else:
                    result = match.group(positions.get(key))
                ret[key] = result
            return ret
        if error_present is True:
            log.info('Configured regex did not match for os: %s tag %s', self._name, msg_dict.get('tag', ''))
        else:
            log.info('Syslog message not configured for os: %s tag %s', self._name, msg_dict.get('tag', ''))
947333
function _parseSmartErrorLog(lines) {
        var resultObj = {};

        //Parse first line to get revision number
        //Example data:
        //SMART Error Log Version: 1
        if (lines.length > 0) {
            resultObj.Revision = (lines[0].substring(
                lines[0].lastIndexOf(' ') + 1)).trim();
        }

        //TODO: need to implement the error log parser

        resultObj['Error Log Table'] = [];
        if (lines.length > 1 && lines[1].startsWith('No ')) {
            return resultObj;
        }
        //resultObj['Error Log Table'] = _parseSmartTable(lines, 1);

        return resultObj;
    }