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


Python Context.get_logger方法代码示例

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


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

示例1: main

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import get_logger [as 别名]
def main():

    parser = argparse.ArgumentParser(description="Scraping for Oscar")

    parser.add_argument(
        "command", type=command_type, help="One of the following options: %s" % ", ".join(command_list()), nargs="?"
    )

    parser.add_argument(
        "--term",
        type=term_type,
        help='Semester and year such as "summer 2007"' " (defaults to the latest term)",
        metavar="",
    )

    parser.add_argument("--subject", help='Subject such as "cs" or "comp sci"', metavar="")

    parser.add_argument("--number", help='Course number such as "1101" or "8803"', metavar="")

    parser.add_argument(
        "--course",
        type=course_type,
        help='Course such as "CS2110" or "psych 1101" ' "(equivalent to --subject and --number)",
        metavar="",
    )

    parser.add_argument("--section", help='Section name such as "A" or "B"', metavar="")

    parser.add_argument("--crn", help="CRN (number that identifies a section)", metavar="")

    parser.add_argument(
        "--offline", dest="enable_http", action="store_false", help="Disable network access and use only cached data"
    )

    parser.add_argument(
        "--refresh",
        action="store_true",
        help="Fetch the most recent information from the " "server, regardless of the cache state",
    )

    parser.add_argument("--verbose", action="store_true", help="Print logging output")

    parser.add_argument(
        "--quiet",
        dest="chatty",
        action="store_false",
        help="Do not print anything beyond the output " "requested by the command",
    )

    parser.add_argument(
        "--log-http",
        dest="log_http",
        action="store_true",
        help="Log HTTP requests and responses to disk " "(warning: this could include authentication credentials)",
    )

    args = parser.parse_args()

    context = Context()

    if args.chatty:
        print ""

    if args.verbose:
        context.get_logger().addHandler(log_handler())

    store = Store(context=context, enable_http=args.enable_http, log_http=args.log_http, force_refresh=args.refresh)

    if args.subject is not None:
        subject = store.find_subject(args.subject)
        args.subject = subject

    if args.command:
        args.command(args, store)

    if args.chatty:
        print ""
开发者ID:alecgorge,项目名称:grouch,代码行数:79,代码来源:ui.py

示例2: main

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import get_logger [as 别名]
def main():
    parser = argparse.ArgumentParser(
        description='Scraping for Oscar'
    )

    parser.add_argument(
        'command',
        type=command_type,
        help='One of the following options: %s' \
             % ', '.join(command_list()),
        nargs='?',
    )

    parser.add_argument(
        '--term',
        type=term_type,
        help='Semester and year such as "summer 2007"' \
             ' (defaults to the latest term)',
        metavar='',
    )

    parser.add_argument(
        '--subject',
        help='Subject such as "cs" or "comp sci"',
        metavar='',
    )

    parser.add_argument(
        '--number',
        help='Course number such as "1101" or "8803"',
        metavar='',
    )

    parser.add_argument(
        '--course',
        type=course_type,
        help='Course such as "CS2110" or "psych 1101" '
             '(equivalent to --subject and --number)',
        metavar='',
    )

    parser.add_argument(
        '--section',
        help='Section name such as "A" or "B"',
        metavar='',
    )

    parser.add_argument(
        '--crn',
        help='CRN (number that identifies a section)',
        metavar='',
    )

    parser.add_argument(
        '--offline',
        dest='enable_http',
        action='store_false',
        help='Disable network access and use only cached data',
    )

    parser.add_argument(
        '--refresh',
        action='store_true',
        help='Fetch the most recent information from the ' \
             'server, regardless of the cache state'
    )

    parser.add_argument(
        '--verbose',
        action='store_true',
        help='Print logging output',
    )

    parser.add_argument(
        '--quiet',
        dest='chatty',
        action='store_false',
        help='Do not print anything beyond the output '
             'requested by the command',
    )

    parser.add_argument(
        '--log-http',
        dest='log_http',
        action='store_true',
        help='Log HTTP requests and responses to disk '
             '(warning: this could include authentication credentials)',
    )

    args = parser.parse_args()

    context = Context()

    if args.chatty:
        print('')

    if args.verbose:
        context.get_logger().addHandler(log_handler())

    store = Store(
#.........这里部分代码省略.........
开发者ID:chris-martin,项目名称:grouch,代码行数:103,代码来源:ui.py


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