当前位置: 首页>>代码示例>>Python>>正文


Python Logger.add_error方法代码示例

本文整理汇总了Python中lib.reporting.logger.Logger.add_error方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.add_error方法的具体用法?Python Logger.add_error怎么用?Python Logger.add_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.reporting.logger.Logger的用法示例。


在下文中一共展示了Logger.add_error方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wrap

# 需要导入模块: from lib.reporting.logger import Logger [as 别名]
# 或者: from lib.reporting.logger.Logger import add_error [as 别名]
 def wrap(instruction_line, tokens):
     try:
         rv = f(instruction_line, tokens)
         if rv is None:
             raise InstructionSyntaxException("")
         else:
             return rv
     except InstructionSyntaxException:
         Logger.add_error("Invalid instruction: '%s'. Instruction ignored" % instruction_line)
         raise
开发者ID:rickardlindberg,项目名称:autopilot,代码行数:12,代码来源:parser.py

示例2: describe_window

# 需要导入模块: from lib.reporting.logger import Logger [as 别名]
# 或者: from lib.reporting.logger.Logger import add_error [as 别名]
 def describe_window(self, hwnd=None):
     if facade.has_win_implementation():
         try:
             nbr_of_children = len(facade.get_children(hwnd))
             if hwnd is None:
                 hwnd = facade.get_active_window()
             rect = facade.get_window_rect(hwnd)
             Logger.bold_header("Window Description \n   hwnd:            %d \n   Classname:       '%s' \n   Label:           '%s'\n   Nbr of children: %d\n   Position:        (%d, %d)\n   Size:            (%d, %d)" % (
                 hwnd, facade.get_classname(hwnd), facade.get_window_text(hwnd), nbr_of_children, rect[0], rect[1], rect[2], rect[3]))
             Logger.header2("Native Description")
             self.describe_children(hwnd)
         except Exception, ex:
             Logger.add_error("Native windows description failed")
开发者ID:rogerlindberg,项目名称:autopilot,代码行数:15,代码来源:window.py

示例3: __init__

# 需要导入模块: from lib.reporting.logger import Logger [as 别名]
# 或者: from lib.reporting.logger.Logger import add_error [as 别名]
 def __init__(self, manuscript, timedelay):
     self.timedelay = timedelay
     self.popup = None
     self.execution_started = False
     self.windows = []
     self.instructions = []
     for line in [
         line for line in manuscript.get_instructions() if not line.startswith("#") and len(line.strip()) > 0
     ]:
         try:
             instruction = parse(line)
         except Exception:
             Logger.add_error("Can't parse instruction: '%s'" % line)
             raise
         if instruction is not None:
             self.instructions.append(instruction)
     collector = []
     for instruction in self.instructions:
         collector.append(instruction.to_unicode())
     Logger.header("Effective Instructions:\n   %s" % "\n   ".join(collector))
开发者ID:rogerlindberg,项目名称:autopilot,代码行数:22,代码来源:instructions.py

示例4: run_python_file

# 需要导入模块: from lib.reporting.logger import Logger [as 别名]
# 或者: from lib.reporting.logger.Logger import add_error [as 别名]
def run_python_file(args):
        """Run a python file as if it were the main program on the command line.

        `args` is the argument array to present as sys.argv, including the first
        element representing the file being executed.

        Lifted straight from coverage.py by Ned Batchelder

        """
        try:
            # In Py 2.x, the builtins were in __builtin__
            BUILTINS = sys.modules['__builtin__']
        except KeyError:  # pragma: no cover - not worried about Python 3 yet...
            # In Py 3.x, they're in builtins
            BUILTINS = sys.modules['builtins']

        filename = args[0]

        # Create a module to serve as __main__
        old_main_mod = sys.modules['__main__']
        main_mod = imp.new_module('__main__')
        sys.modules['__main__'] = main_mod
        main_mod.__file__ = filename
        main_mod.__builtins__ = BUILTINS

        # Set sys.argv and the first path element properly.
        old_argv = sys.argv
        old_path0 = sys.path[0]
        sys.argv = args
        sys.path[0] = os.path.dirname(filename)

        try:
            sys.stdout = open('outfile.txt', 'w')
            source = open(filename, 'rU').read()
            exec compile(source, filename, "exec") in main_mod.__dict__
        except Exception, ex:
            Logger.add_error("%s" % ex)
            Logger.failure("Exception in application")
开发者ID:rogerlindberg,项目名称:autopilot,代码行数:40,代码来源:pythonlauncher.py

示例5: scan

# 需要导入模块: from lib.reporting.logger import Logger [as 别名]
# 或者: from lib.reporting.logger.Logger import add_error [as 别名]

#.........这里部分代码省略.........
        token = UNKNOWN
        subid = None

        # Comment
        if i == 0 and text[i] == '#':
            lexeme = text.decode("utf-8")
            typename = "Comment"
            token = Token(KEYWORD, text, ID_COMMENT, col=0)
            tokens.append(token)
            return tokens

        # Space
        elif text[i] == ' ':
            lexeme = u" "
            typename = "Space"
            token = SPACE

        # Tab
        elif text[i] == '\t':
            lexeme = u" "
            typename = "Tab"
            token = TAB
            _tab_count = _tab_count + 1

        # Left Parenthesis
        elif text[i] == '(':
            lexeme = u"("
            typename = "Left Parenthesis"
            token = LP

        # Right Parenthesis
        elif text[i] == ')':
            lexeme = u")"
            typename = "Right Parenthesis"
            token = RP

        elif text[i] == '=':
            lexeme = u"="
            typename = "Equal sign"
            token = EQ

        elif text[i] == '+':
            lexeme = u"+"
            typename = "Plus sign"
            token = PLUS

        elif text[i] == ',':
            lexeme = u","
            typename = "Comma"
            token = COMMA

        elif text[i] == '|':
            lexeme = u"|"
            typename = "Or"
            token = OR

        elif text[i] == '"':
            lexeme, token, subid, i = _parse_string(text, i)
            typename = "String"
            _col = i + 1

        elif text[i] == "'":
            lexeme, token, subid, i = _parse_string(text, i)
            typename = "String"
            _col = i + 1

        elif text[i].isalnum() or text[i] in ID_SPECIAL_CHARS:
            lexeme, token, subid, i = _parse_identifier(text, i)
            typename = "Identifier"
            _col = i + 1

        # Unknown token
        else:
            if text[i].isspace():
                lexeme = u" "
                typename = "Space"
                token = SPACE
            else:
                nbr_of_unkown = nbr_of_unkown + 1
                lexeme = u"%c" % text[i]

        i += 1
        _col += 1

        # Print result
        if _print_unknown_only:
            if (token == UNKNOWN):
                msg = "%d %d %s %s" % (i, token, typename, lexeme)
                Logger.add_error(msg)

        if typename != "Space":
            token = Token(token, lexeme, subid, col=prevcol)
            tokens.append(token)
        prevcol = _col

    if nbr_of_unkown > 0:
        msg = "Nbr of unknown tokens encountered = %d" % nbr_of_unkown
        Logger.add_error(msg)

    return tokens
开发者ID:rogerlindberg,项目名称:autopilot,代码行数:104,代码来源:scanner.py

示例6: __init__

# 需要导入模块: from lib.reporting.logger import Logger [as 别名]
# 或者: from lib.reporting.logger.Logger import add_error [as 别名]
 def __init__(self, msg):
     Logger.add_error(msg)
开发者ID:rogerlindberg,项目名称:autopilot,代码行数:4,代码来源:exceptions.py


注:本文中的lib.reporting.logger.Logger.add_error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。