コード例 #1
0
ファイル: log.py プロジェクト: FilipB/cfme_tests
 def filter(self, record):
     try:
         relpath = get_rel_path(record.source_file)
         lineno = record.source_lineno
     except AttributeError:
         relpath = get_rel_path(record.pathname)
         lineno = record.lineno
     if lineno:
         record.source = "{}:{}".format(relpath, lineno)
     else:
         record.source = relpath
     return True
コード例 #2
0
ファイル: log.py プロジェクト: jkrocil/integration_tests
    def filter(self, record):
        try:
            relpath = get_rel_path(record.source_file) or record.source_file
            lineno = record.source_lineno
        except AttributeError:
            relpath = get_rel_path(record.pathname) or record.pathname
            lineno = record.lineno
        if lineno:
            record.source = "%s:%d" % (relpath, lineno)
        else:
            record.source = relpath

        return True
コード例 #3
0
    def filter(self, record):
        try:
            relpath = get_rel_path(record.source_file)
            lineno = record.source_lineno
        except AttributeError:
            relpath = get_rel_path(record.pathname)
            lineno = record.lineno
        if lineno:
            record.source = "{}:{}".format(relpath, lineno)
        else:
            record.source = relpath

        return True
コード例 #4
0
ファイル: log.py プロジェクト: richardfontana/cfme_tests
def _showwarning(message, category, filename, lineno, file=None, line=None):
    relpath = get_rel_path(filename)
    if relpath:
        # Only show warnings from inside this project
        message = "%s from %s:%d: %s" % (category.__name__, relpath, lineno,
                                         message)
        logger.warning(message)
コード例 #5
0
ファイル: soft_assert.py プロジェクト: jkrocil/cfme_tests
def _annote_failure(fail_message=""):
    # Inspect the stack with 1 line of context, looking at the 2nd frame
    # before this one, assuming the first frame is whatever called this function,
    # and the second frame is where the assertion failure took place
    frameinfo = inspect.getframeinfo(inspect.stack(1)[2][0])
    if not fail_message:
        fail_message = str(frameinfo.code_context[0]).strip()

    filename = get_rel_path(frameinfo.filename) or frameinfo.filename
    path = "%s:%r" % (filename, frameinfo.lineno)
    return "%s (%s)" % (fail_message, path)
コード例 #6
0
ファイル: soft_assert.py プロジェクト: weissjeffm/cfme_tests
    def _soft_assert_func(expr, fail_message=''):
        if not expr:
            # inspect the calling frame to find where the original assertion failed
            # explicitly requesting one line of code context so we can set fail_message if needed
            frameinfo = inspect.getframeinfo(inspect.stack(1)[1][0])
            if not fail_message:
                fail_message = str(frameinfo.code_context[0]).strip()

            path = '%s:%r' % (get_rel_path(frameinfo.filename), frameinfo.lineno)
            fail_message = '%s (%s)' % (fail_message, path)
            _thread_locals.caught_asserts.append(fail_message)
コード例 #7
0
def _annote_failure(fail_message=''):
    # Inspect the stack with 1 line of context, looking at the 2nd frame
    # before this one, assuming the first frame is whatever called this function,
    # and the second frame is where the assertion failure took place
    frameinfo = inspect.getframeinfo(inspect.stack(1)[2][0])
    if not fail_message:
        fail_message = str(frameinfo.code_context[0]).strip()

    filename = get_rel_path(frameinfo.filename) or frameinfo.filename
    path = '%s:%r' % (filename, frameinfo.lineno)
    return '%s (%s)' % (fail_message, path)
コード例 #8
0
ファイル: log.py プロジェクト: vprusa/cfme_tests
def _showwarning(message, category, filename, lineno, file=None, line=None):
    relpath = get_rel_path(filename)
    if relpath:
        # Only show warnings from inside this project
        message = "{} from {}:{}: {}".format(category.__name__, relpath, lineno, message)
        try:
            logger.warning(message)
        except ImportError:
            # In case we have both credentials.eyaml and credentials.yaml, it gets in an import loop
            # Therefore it would raise ImportError for art_client. Let's don't bother and just spit
            # it out. This should reduce number of repeated questions down by 99%.
            print("[WARNING] {}".format(message))
コード例 #9
0
ファイル: log.py プロジェクト: MattLombana/cfme_tests
def _showwarning(message, category, filename, lineno, file=None, line=None):
    relpath = get_rel_path(filename)
    if relpath:
        # Only show warnings from inside this project
        message = "{} from {}:{}: {}".format(category.__name__, relpath, lineno, message)
        try:
            logger.warning(message)
        except ImportError:
            # In case we have both credentials.eyaml and credentials.yaml, it gets in an import loop
            # Therefore it would raise ImportError for art_client. Let's don't bother and just spit
            # it out. This should reduce number of repeated questions down by 99%.
            print("[WARNING] {}".format(message))
コード例 #10
0
def _annotate_failure(fail_message=''):
    # frames
    # 0: call to nth_frame_info
    # 1: _annotate_failure (this function)
    # 2: _annotate_failure caller (soft assert func or CM)
    # 3: failed assertion
    frameinfo = nth_frame_info(3)
    if not fail_message:
        fail_message = str(frameinfo.code_context[0]).strip()

    filename = get_rel_path(frameinfo.filename)
    path = '%s:%r' % (filename, frameinfo.lineno)
    return '%s (%s)' % (fail_message, path)
コード例 #11
0
ファイル: soft_assert.py プロジェクト: FilipB/cfme_tests
def _annotate_failure(fail_message=''):
    # frames
    # 0: call to nth_frame_info
    # 1: _annotate_failure (this function)
    # 2: _annotate_failure caller (soft assert func or CM)
    # 3: failed assertion
    frameinfo = nth_frame_info(3)
    if not fail_message:
        fail_message = str(frameinfo.code_context[0]).strip()

    filename = get_rel_path(frameinfo.filename)
    path = '{}:{!r}'.format(filename, frameinfo.lineno)
    return '{} ({})'.format(fail_message, path)
コード例 #12
0
ファイル: log.py プロジェクト: vrutkovs/cfme_tests
 def process(self, msg, kwargs):
     # frames
     # 0: call to nth_frame_info
     # 1: adapter process method (this method)
     # 2: adapter logging method
     # 3: original logging call
     frameinfo = nth_frame_info(3)
     extra = kwargs.get('extra', {})
     # add extra data if needed
     if not extra.get('source_file'):
         if frameinfo.filename:
             extra['source_file'] = get_rel_path(frameinfo.filename)
             extra['source_lineno'] = frameinfo.lineno
         else:
             # calling frame didn't have a filename
             extra['source_file'] = 'unknown'
             extra['source_lineno'] = 0
     kwargs['extra'] = extra
     return msg, kwargs
コード例 #13
0
ファイル: log.py プロジェクト: seandst/cfme_tests
 def process(self, msg, kwargs):
     # frames
     # 0: call to nth_frame_info
     # 1: adapter process method (this method)
     # 2: adapter logging method
     # 3: original logging call
     frameinfo = nth_frame_info(3)
     extra = kwargs.get('extra', {})
     # add extra data if needed
     if not extra.get('source_file'):
         if frameinfo.filename:
             extra['source_file'] = get_rel_path(frameinfo.filename)
             extra['source_lineno'] = frameinfo.lineno
         else:
             # calling frame didn't have a filename
             extra['source_file'] = 'unknown'
             extra['source_lineno'] = 0
     kwargs['extra'] = extra
     return msg, kwargs
コード例 #14
0
ファイル: log.py プロジェクト: ManageIQ/integration_tests
 def filter(self, record):
     record.pathname = get_rel_path(record.pathname)
     return True
コード例 #15
0
def _showwarning(message, category, filename, lineno, file=None, line=None):
    relpath = get_rel_path(filename)
    if relpath:
        message = "{} from {}:{}: {}".format(category.__name__, relpath,
                                             lineno, message)
        logger.warning(message)
コード例 #16
0
ファイル: log.py プロジェクト: jawatts/integration_tests
 def filter(self, record):
     record.pathname = get_rel_path(record.pathname)
     return True
コード例 #17
0
ファイル: log.py プロジェクト: seandst/cfme_tests
def _showwarning(message, category, filename, lineno, file=None, line=None):
    relpath = get_rel_path(filename)
    if relpath:
        # Only show warnings from inside this project
        message = "%s from %s:%d: %s" % (category.__name__, relpath, lineno, message)
        logger.warning(message)