• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python commandline.setup_logging函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mozlog.structured.commandline.setup_logging函数的典型用法代码示例。如果您正苦于以下问题:Python setup_logging函数的具体用法?Python setup_logging怎么用?Python setup_logging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: cli

def cli(args=sys.argv[1:]):
    worker_map = {
        'rq': rq_worker,
        'sqs': busy_wait_worker,
        'mongo': burst_worker,
    }

    parser = argparse.ArgumentParser()
    parser.add_argument('queue',
                        choices=worker_map.keys(),
                        help='The work queue the workers should grab jobs from.')
    parser.add_argument('-j',
                        dest='num_workers',
                        type=int,
                        default=1,
                        help='The number of worker processes to spawn.')
    # setup logging args
    commandline.log_formatters = { k: v for k, v in commandline.log_formatters.iteritems() if k in ('raw', 'mach') }
    commandline.add_logging_group(parser)

    args = vars(parser.parse_args(args))
    commandline.setup_logging("catalog-worker", args)

    qname = args['queue']
    process_class = Process
    if qname == 'rq':
        process_class = Thread

    for _ in range(args['num_workers']):
        worker = process_class(target=worker_map[qname], args=(qname,))
        worker.start()
开发者ID:ahal,项目名称:structured-catalog,代码行数:31,代码来源:run_workers.py


示例2: run_marionette

def run_marionette(tests, binary=None, topsrcdir=None, **kwargs):
    from mozlog.structured import commandline

    from marionette.runtests import (
        MarionetteTestRunner,
        MarionetteHarness
    )

    parser = setup_marionette_argument_parser()

    if not tests:
        tests = [os.path.join(topsrcdir,
                 'testing/marionette/harness/marionette/tests/unit-tests.ini')]

    args = argparse.Namespace(tests=tests)

    args.binary = binary

    for k, v in kwargs.iteritems():
        setattr(args, k, v)

    parser.verify_usage(args)

    args.logger = commandline.setup_logging("Marionette Unit Tests",
                                            args,
                                            {"mach": sys.stdout})
    failed = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run()
    if failed > 0:
        return 1
    else:
        return 0
开发者ID:lazyparser,项目名称:gecko-dev,代码行数:31,代码来源:mach_commands.py


示例3: run_marionette

def run_marionette(tests, testtype=None, address=None, binary=None, topsrcdir=None, **kwargs):
    from mozlog.structured import commandline

    from marionette.runtests import (
        MarionetteTestRunner,
        BaseMarionetteArguments,
        MarionetteHarness
    )

    parser = BaseMarionetteArguments()
    commandline.add_logging_group(parser)

    if not tests:
        tests = [os.path.join(topsrcdir,
                 'testing/marionette/harness/marionette/tests/unit-tests.ini')]

    args = parser.parse_args(args=tests)

    args.binary = binary
    path, exe = os.path.split(args.binary)

    for k, v in kwargs.iteritems():
        setattr(args, k, v)

    parser.verify_usage(args)

    args.logger = commandline.setup_logging("Marionette Unit Tests",
                                            args,
                                            {"mach": sys.stdout})
    failed = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run()
    if failed > 0:
        return 1
    else:
        return 0
开发者ID:emilio,项目名称:gecko-dev,代码行数:34,代码来源:mach_commands.py


示例4: __init__

    def __init__(self, options):
        self.options = options
        self.logger = commandline.setup_logging("mozregression",
                                                self.options,
                                                {"mach": sys.stdout})
        # allow to filter process output based on the user option
        if options.process_output is None:
            # process_output not user defined
            log_process_output = options.build_type != 'opt'
        else:
            log_process_output = options.process_output == 'stdout'
        get_default_logger("process").component_filter = \
            lambda data: data if log_process_output else None

        # filter some mozversion log lines
        re_ignore_mozversion_line = re.compile(
            r"^(platform_.+|application_vendor|application_remotingname"
            r"|application_id|application_display_name): .+"
        )
        get_default_logger("mozversion").component_filter = lambda data: (
            None if re_ignore_mozversion_line.match(data['message']) else data
        )

        self.action = None
        self.fetch_config = None
开发者ID:crisron,项目名称:mozregression-1,代码行数:25,代码来源:cli.py


示例5: __init__

 def __init__(self, options):
     self.options = options
     self.logger = commandline.setup_logging("mozregression",
                                             self.options,
                                             {"mach": sys.stdout})
     self.action = None
     self.fetch_config = None
开发者ID:xennygrimmato,项目名称:mozregression,代码行数:7,代码来源:cli.py


示例6: run_marionette

def run_marionette(context, **kwargs):
    from marionette.runtests import (
        MarionetteTestRunner,
        MarionetteHarness
    )
    from mozlog.structured import commandline


    args = argparse.Namespace(**kwargs)

    if not args.binary:
        args.binary = context.find_firefox()

    test_root = os.path.join(context.package_root, 'marionette', 'tests')
    if not args.tests:
        args.tests = [os.path.join(test_root, 'testing', 'marionette', 'harness',
                                   'marionette', 'tests', 'unit-tests.ini')]

    normalize = partial(context.normalize_test_path, test_root)
    args.tests = map(normalize, args.tests)

    commandline.add_logging_group(parser)
    parser.verify_usage(args)

    args.logger = commandline.setup_logging("Marionette Unit Tests",
                                            args,
                                            {"mach": sys.stdout})
    status = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run()
    return 1 if status else 0
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:29,代码来源:mach_test_package_commands.py


示例7: run_cppunit_test

    def run_cppunit_test(self, **params):
        import mozinfo
        from mozlog.structured import commandline
        import runcppunittests as cppunittests

        log = commandline.setup_logging("cppunittest",
                                        {},
                                        {"tbpl": sys.stdout})

        if len(params['test_files']) == 0:
            testdir = os.path.join(self.distdir, 'cppunittests')
            tests = cppunittests.extract_unittests_from_args([testdir], mozinfo.info)
        else:
            tests = cppunittests.extract_unittests_from_args(params['test_files'], mozinfo.info)

        # See if we have crash symbols
        symbols_path = os.path.join(self.distdir, 'crashreporter-symbols')
        if not os.path.isdir(symbols_path):
            symbols_path = None

        tester = cppunittests.CPPUnitTests()
        try:
            result = tester.run_tests(tests, self.bindir, symbols_path, interactive=True)
        except Exception as e:
            log.error("Caught exception running cpp unit tests: %s" % str(e))
            result = False

        return 0 if result else 1
开发者ID:haasn,项目名称:gecko-dev,代码行数:28,代码来源:mach_commands.py


示例8: main

def main():
    parser = argparse.ArgumentParser()
    dsn = 'dbname=autoland user=autoland host=localhost password=autoland'
    parser.add_argument('--dsn', default=dsn,
                        help="Postgresql DSN connection string")
    commandline.add_logging_group(parser)
    args = parser.parse_args()

    logging.basicConfig()
    logger = commandline.setup_logging('autoland', vars(args), {})
    logger.info('starting autoland')

    auth = selfserve.read_credentials()
    if auth is None:
        logger.critical('could not read selfserve credentials. aborting')
        return

    dbconn = psycopg2.connect(args.dsn)

    # this should exceed the stable delay in buildapi
    stable_delay = datetime.timedelta(minutes=5)
    old_job = datetime.timedelta(minutes=30)

    while True:
        try:
            cursor = dbconn.cursor()
            now = datetime.datetime.now()

            # handle potentially finished autoland jobs
            query = """select tree,revision from Autoland
                       where pending=0 and running=0 and last_updated<=%(time)s
                       and can_be_landed is null"""
            cursor.execute(query, ({'time': now - stable_delay}))
            for row in cursor.fetchall():
                tree, rev = row
                handle_autoland_request(logger, auth, dbconn, tree, rev)

            # we also look for any older jobs - maybe something got missed
            # in pulse
            query = """select tree,revision from Autoland
                       where last_updated<=%(time)s
                       and can_be_landed is null"""
            cursor.execute(query, ({'time': now - old_job}))
            for row in cursor.fetchall():
                tree, rev = row
                handle_autoland_request(logger, auth, dbconn, tree, rev)

            #
            handle_pending_bugzilla_comments(logger, dbconn)

            #
            handle_pending_transplants(logger, dbconn)

            time.sleep(30)

        except KeyboardInterrupt:
            break
        except:
            t, v, tb = sys.exc_info()
            logger.error('\n'.join(traceback.format_exception(t, v, tb)))
开发者ID:jamonation,项目名称:autoland,代码行数:60,代码来源:autoland.py


示例9: main

def main(argv):
    parser = get_parser()
    args = parser.parse_args(argv[1:])
    logger = commandline.setup_logging("webapi", args, {"mach": sys.stdout})

    test_loader = TestLoader()
    tests = []
    if len(args.tests) >= 1 and args.tests[0] == "discover":
        start_dir = args.tests[1] if len(args.tests) > 1 else "."
        tests = test_loader.discover(start_dir, args.pattern or "test_*.py")
    else:
        tests = None
        if len(args.tests) > 0:
            tests = test_loader.loadTestsFromNames(args.tests, None)
        else:
            tests = unittest.TestSuite()

    results = run(
        tests,
        spawn_browser=not args.no_browser,
        verbosity=2 if args.verbose else 1,
        failfast=args.failfast,
        catch_break=args.catch,
        buffer=args.buffer,
        logger=logger,
    )
    sys.exit(not results.wasSuccessful())
开发者ID:pombredanne,项目名称:fxos-certsuite,代码行数:27,代码来源:main.py


示例10: test_setup_logging_optparse

 def test_setup_logging_optparse(self):
     parser = optparse.OptionParser()
     commandline.add_logging_group(parser)
     args, _ = parser.parse_args(["--log-raw=-"])
     logger = commandline.setup_logging("test_optparse", args, {})
     self.assertEqual(len(logger.handlers), 1)
     self.assertIsInstance(logger.handlers[0], handlers.StreamHandler)
开发者ID:mlasak,项目名称:gecko-dev,代码行数:7,代码来源:test_structured.py


示例11: run_external_media_test

def run_external_media_test(tests, testtype=None, topsrcdir=None, **kwargs):
    from external_media_harness.runtests import (
        FirefoxMediaHarness,
        MediaTestArguments,
        MediaTestRunner,
        mn_cli,
    )

    from mozlog.structured import commandline

    parser = MediaTestArguments()
    commandline.add_logging_group(parser)

    if not tests:
        tests = [os.path.join(topsrcdir,
                 'dom/media/test/external/external_media_tests/manifest.ini')]

    args = parser.parse_args(args=tests)

    for k, v in kwargs.iteritems():
        setattr(args, k, v)

    parser.verify_usage(args)

    args.logger = commandline.setup_logging("Firefox External Media Tests",
                                            args,
                                            {"mach": sys.stdout})
    failed = mn_cli(MediaTestRunner, MediaTestArguments, FirefoxMediaHarness,
                    args=args)

    if failed > 0:
        return 1
    else:
        return 0
开发者ID:Shaif95,项目名称:gecko-dev,代码行数:34,代码来源:mach_commands.py


示例12: run_firefox_ui_test

def run_firefox_ui_test(tests, testtype=None, topsrcdir=None, **kwargs):
    from mozlog.structured import commandline
    from firefox_ui_harness import cli_functional
    from firefox_ui_harness.arguments import FirefoxUIArguments

    parser = FirefoxUIArguments()
    commandline.add_logging_group(parser)

    if not tests:
        tests = [os.path.join(topsrcdir,
                 'testing/firefox-ui/tests/firefox_ui_tests/manifest.ini')]

    args = parser.parse_args(args=tests)

    for k, v in kwargs.iteritems():
        setattr(args, k, v)

    parser.verify_usage(args)

    args.logger = commandline.setup_logging("Firefox UI - Functional Tests",
                                            args,
                                            {"mach": sys.stdout})
    failed = cli_functional.mn_cli(cli_functional.FirefoxUITestRunner, args=args)
    if failed > 0:
        return 1
    else:
        return 0
开发者ID:spatenotte,项目名称:gecko,代码行数:27,代码来源:mach_commands.py


示例13: main

def main():
    parser = argparse.ArgumentParser()

    dsn = config.get('database')

    parser.add_argument('--dsn', default=dsn,
                        help="Postgresql DSN connection string")
    commandline.add_logging_group(parser)
    args = parser.parse_args()

    logging.basicConfig()
    logger = commandline.setup_logging('autoland', vars(args), {})
    logger.info('starting autoland')

    dbconn = get_dbconn(args.dsn)
    last_error_msg = None
    while True:
        try:
            handle_pending_mozreview_pullrequests(logger, dbconn)
            handle_pending_transplants(logger, dbconn)
            handle_pending_github_updates(logger, dbconn)
            handle_pending_mozreview_updates(logger, dbconn)
            time.sleep(0.25)
        except KeyboardInterrupt:
            break
        except psycopg2.InterfaceError:
            dbconn = get_dbconn(args.dsn)
        except:
            # If things go really badly, we might see the same exception
            # thousands of times in a row. There's not really any point in
            # logging it more than once.
            error_msg = traceback.format_exc()
            if error_msg != last_error_msg:
                logger.error(error_msg)
                last_error_msg = error_msg
开发者ID:Nephyrin,项目名称:bzexport,代码行数:35,代码来源:autoland.py


示例14: run_firefox_ui_test

def run_firefox_ui_test(testtype=None, topsrcdir=None, **kwargs):
    from mozlog.structured import commandline
    from argparse import Namespace
    import firefox_ui_harness

    if testtype == 'functional':
        parser = setup_argument_parser_functional()
    else:
        parser = setup_argument_parser_update()

    test_types = {
        'functional': {
            'default_tests': [
                os.path.join('puppeteer', 'manifest.ini'),
                os.path.join('functional', 'manifest.ini'),
            ],
            'cli_module': firefox_ui_harness.cli_functional,
        },
        'update': {
            'default_tests': [
                os.path.join('update', 'manifest.ini'),
            ],
            'cli_module': firefox_ui_harness.cli_update,
        }
    }

    fxui_dir = os.path.join(topsrcdir, 'testing', 'firefox-ui')

    # Set the resources path which is used to serve test data via wptserve
    if not kwargs['server_root']:
        kwargs['server_root'] = os.path.join(fxui_dir, 'resources')

    # If called via "mach test" a dictionary of tests is passed in
    if 'test_objects' in kwargs:
        tests = []
        for obj in kwargs['test_objects']:
            tests.append(obj['file_relpath'])
        kwargs['tests'] = tests
    elif not kwargs.get('tests'):
        # If no tests have been selected, set default ones
        kwargs['tests'] = [os.path.join(fxui_dir, 'tests', test)
                           for test in test_types[testtype]['default_tests']]

    kwargs['logger'] = commandline.setup_logging('Firefox UI - {} Tests'.format(testtype),
                                                 {"mach": sys.stdout})

    args = Namespace()

    for k, v in kwargs.iteritems():
        setattr(args, k, v)

    parser.verify_usage(args)

    failed = test_types[testtype]['cli_module'].cli(args=vars(args))

    if failed > 0:
        return 1
    else:
        return 0
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:59,代码来源:mach_commands.py


示例15: main

def main():
    parser = B2GOptions()
    structured.commandline.add_logging_group(parser)
    options, args = parser.parse_args()
    log = commandline.setup_logging("Remote XPCShell",
                                    options,
                                    {"tbpl": sys.stdout})
    run_remote_xpcshell(parser, options, args, log)
开发者ID:Antonius32,项目名称:Pale-Moon,代码行数:8,代码来源:runtestsb2g.py


示例16: cli

def cli():
    global webapi_results
    global webapi_results_embed_app

    parser = argparse.ArgumentParser()
    parser.add_argument("--version",
                        help="version of FxOS under test",
                        default="1.3",
                        action="store")
    parser.add_argument("--debug",
                        help="enable debug logging",
                        action="store_true")
    parser.add_argument("--list-test-groups",
                        help="print test groups available to run",
                        action="store_true")
    parser.add_argument("--include",
                        metavar="TEST-GROUP",
                        help="include this test group",
                        action="append")
    parser.add_argument("--result-file",
                        help="absolute file path to store the resulting json." \
                             "Defaults to results.json on your current path",
                        action="store")
    parser.add_argument("--generate-reference",
                        help="Generate expected result files",
                        action="store_true")
    commandline.add_logging_group(parser)

    args = parser.parse_args()

    test_groups = [
        'omni-analyzer',
        'permissions',
        'webapi',
        ]
    if args.list_test_groups:
        for t in test_groups:
            print t
        return 0

    test_groups = set(args.include if args.include else test_groups)
    report = {'buildprops': {}}

    logging.basicConfig()
    if not args.debug:
        logging.disable(logging.ERROR)

    logger = commandline.setup_logging("certsuite", vars(args), {})

    # Step 1: Get device information
    try:
        dm = mozdevice.DeviceManagerADB()
    except mozdevice.DMError, e:
        print "Error connecting to device via adb (error: %s). Please be " \
            "sure device is connected and 'remote debugging' is enabled." % \
            e.msg
        logger.error("Error connecting to device: %s" % e.msg)
        sys.exit(1)
开发者ID:jonallengriffin,项目名称:fxos-certsuite,代码行数:58,代码来源:cert.py


示例17: cli

def cli(argv=None):
    """
    main entry point of mozregression command line.
    """
    options = parse_args(argv)
    logger = commandline.setup_logging("mozregression",
                                       options,
                                       {"mach": sys.stdout})
    check_mozregression_version(logger)

    if options.list_releases:
        print(formatted_valid_release_dates())
        sys.exit()

    cache_session = limitedfilecache.get_cache(
        options.http_cache_dir, limitedfilecache.ONE_GIGABYTE,
        logger=get_default_logger('Limited File Cache'))
    set_http_cache_session(cache_session,
                           get_defaults={"timeout": options.http_timeout})

    fetch_config = create_config(options.app, mozinfo.os, options.bits)

    if options.command is None:
        launcher_kwargs = dict(
            addons=options.addons,
            profile=options.profile,
            cmdargs=options.cmdargs,
            preferences=preference(options.prefs_files, options.prefs),
        )
        test_runner = ManualTestRunner(launcher_kwargs=launcher_kwargs)
    else:
        test_runner = CommandTestRunner(options.command)

    runner = ResumeInfoBisectRunner(fetch_config, test_runner, options)

    if fetch_config.is_inbound():
        # this can be useful for both inbound and nightly, because we
        # can go to inbound from nightly.
        fetch_config.set_inbound_branch(options.inbound_branch)

    # bisect inbound if last good revision or first bad revision are set
    if options.first_bad_revision or options.last_good_revision:
        bisect = bisect_inbound
    else:
        bisect = bisect_nightlies

    try:
        launcher_class = APP_REGISTRY.get(fetch_config.app_name)
        launcher_class.check_is_runnable()

        sys.exit(bisect(runner, logger))
    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except UnavailableRelease as exc:
        sys.exit("%s\n%s" % (exc, formatted_valid_release_dates()))
    except (MozRegressionError, RequestException) as exc:
        sys.exit(str(exc))
开发者ID:askeing,项目名称:mozregression,代码行数:57,代码来源:main.py


示例18: setup

def setup(args, defaults):
    logger = commandline.setup_logging("web-platform-tests", args, defaults)
    setup_stdlib_logger()

    for name in args.keys():
        if name.startswith("log_"):
            args.pop(name)

    return logger
开发者ID:AlanWasTaken,项目名称:servo,代码行数:9,代码来源:wptlogging.py


示例19: setup_logging

def setup_logging(args, defaults):
    global logger
    logger = commandline.setup_logging("web-platform-tests-update", args, defaults)

    for name in args.keys():
        if name.startswith("log_"):
            args.pop(name)

    return logger
开发者ID:ashishrana7,项目名称:firefox,代码行数:9,代码来源:update.py


示例20: main

def main():

    if sys.version_info < (2,7):
        print >>sys.stderr, "Error: You must use python version 2.7 or newer but less than 3.0"
        sys.exit(1)

    parser = RemoteXPCShellOptions()
    structured.commandline.add_logging_group(parser)
    options, args = parser.parse_args()
    if not options.localAPK:
        for file in os.listdir(os.path.join(options.objdir, "dist")):
            if (file.endswith(".apk") and file.startswith("fennec")):
                options.localAPK = os.path.join(options.objdir, "dist")
                options.localAPK = os.path.join(options.localAPK, file)
                print >>sys.stderr, "using APK: " + options.localAPK
                break
        else:
            print >>sys.stderr, "Error: please specify an APK"
            sys.exit(1)

    options = parser.verifyRemoteOptions(options)
    log = commandline.setup_logging("Remote XPCShell",
                                    options,
                                    {"tbpl": sys.stdout})

    if len(args) < 1 and options.manifest is None:
        print >>sys.stderr, """Usage: %s <test dirs>
             or: %s --manifest=test.manifest """ % (sys.argv[0], sys.argv[0])
        sys.exit(1)

    if options.dm_trans == "adb":
        if options.deviceIP:
            dm = mozdevice.DroidADB(options.deviceIP, options.devicePort, packageName=None, deviceRoot=options.remoteTestRoot)
        else:
            dm = mozdevice.DroidADB(packageName=None, deviceRoot=options.remoteTestRoot)
    else:
        if not options.deviceIP:
            print "Error: you must provide a device IP to connect to via the --device option"
            sys.exit(1)
        dm = mozdevice.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)

    if options.interactive and not options.testPath:
        print >>sys.stderr, "Error: You must specify a test filename in interactive mode!"
        sys.exit(1)

    xpcsh = XPCShellRemote(dm, options, args, log)

    # we don't run concurrent tests on mobile
    options.sequential = True

    if not xpcsh.runTests(xpcshell='xpcshell',
                          testClass=RemoteXPCShellTestThread,
                          testdirs=args[0:],
                          mobileArgs=xpcsh.mobileArgs,
                          **options.__dict__):
        sys.exit(1)
开发者ID:html-shell,项目名称:mozbuild,代码行数:56,代码来源:remotexpcshelltests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python reader.read函数代码示例发布时间:2022-05-27
下一篇:
Python commandline.add_logging_group函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap