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

Python commandline.add_logging_group函数代码示例

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

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



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

示例1: 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


示例2: create_parser

def create_parser():
    p = argparse.ArgumentParser()
    p.add_argument("--check-clean", action="store_true",
                   help="Check that updating the manifest doesn't lead to any changes")
    commandline.add_logging_group(p)

    return p
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:7,代码来源:manifestupdate.py


示例3: 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


示例4: 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


示例5: 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


示例6: 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


示例7: create_parser_update

def create_parser_update():
    from mozlog.structured import commandline

    parser = argparse.ArgumentParser("web-platform-tests-update",
                                     description="Update script for web-platform-tests tests.")
    parser.add_argument("--config", action="store", type=abs_path, help="Path to config file")
    parser.add_argument("--metadata", action="store", type=abs_path, dest="metadata_root",
                        help="Path to the folder containing test metadata"),
    parser.add_argument("--tests", action="store", type=abs_path, dest="tests_root",
                        help="Path to web-platform-tests"),
    parser.add_argument("--sync-path", action="store", type=abs_path,
                        help="Path to store git checkout of web-platform-tests during update"),
    parser.add_argument("--remote_url", action="store",
                        help="URL of web-platfrom-tests repository to sync against"),
    parser.add_argument("--branch", action="store", type=abs_path,
                        help="Remote branch to sync against")
    parser.add_argument("--rev", action="store", help="Revision to sync to")
    parser.add_argument("--no-patch", action="store_true",
                        help="Don't create an mq patch or git commit containing the changes.")
    parser.add_argument("--sync", dest="sync", action="store_true", default=False,
                        help="Sync the tests with the latest from upstream")
    parser.add_argument("--ignore-existing", action="store_true", help="When updating test results only consider results from the logfiles provided, not existing expectations.")
    parser.add_argument("--continue", action="store_true", help="Continue a previously started run of the update script")
    parser.add_argument("--abort", action="store_true", help="Clear state from a previous incomplete run of the update script")
    # Should make this required iff run=logfile
    parser.add_argument("run_log", nargs="*", type=abs_path,
                        help="Log file from run of tests")
    commandline.add_logging_group(parser)
    return parser
开发者ID:yangkkokk,项目名称:gecko-dev,代码行数:29,代码来源:wptcommandline.py


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: test_logging_errorlevel

    def test_logging_errorlevel(self):
        parser = argparse.ArgumentParser()
        commandline.add_logging_group(parser)
        args = parser.parse_args(["--log-tbpl=%s" % self.logfile.name, "--log-tbpl-level=error"])
        logger = commandline.setup_logging("test_fmtopts", args, {})
        logger.info("INFO message")
        logger.debug("DEBUG message")
        logger.error("ERROR message")

        # Only the error level and above were requested.
        self.assertEqual(["ERROR message"],
                         self.loglines)
开发者ID:mlasak,项目名称:gecko-dev,代码行数:12,代码来源:test_structured.py


示例13: run_marionette

def run_marionette(tests, b2g_path=None, emulator=None, testtype=None,
    address=None, binary=None, topsrcdir=None, **kwargs):

    # Import the harness directly and under a different name here to avoid
    # "marionette" being importable from two locations when "testing/marionette/client"
    # is on sys.path.
    # See bug 1050511 and bug 1114474. This needs to be removed with the
    # resolution of bug 1109183.
    clientdir = os.path.join(topsrcdir, 'testing/marionette/client')
    if clientdir in sys.path:
        sys.path.remove(clientdir)
    path = os.path.join(topsrcdir, 'testing/marionette/client/marionette/runtests.py')
    with open(path, 'r') as fh:
        imp.load_module('marionetteharness', fh, path,
                        ('.py', 'r', imp.PY_SOURCE))

    from marionetteharness import (
        MarionetteTestRunner,
        BaseMarionetteOptions,
        startTestRunner
    )

    parser = BaseMarionetteOptions()
    commandline.add_logging_group(parser)
    options, args = parser.parse_args()

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

    if b2g_path:
        options.homedir = b2g_path
        if emulator:
            options.emulator = emulator
    else:
        options.binary = binary
        path, exe = os.path.split(options.binary)

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

    parser.verify_usage(options, tests)

    options.logger = commandline.setup_logging("Marionette Unit Tests",
                                               options,
                                               {"mach": sys.stdout})

    runner = startTestRunner(MarionetteTestRunner, options, tests)
    if runner.failed > 0:
        return 1

    return 0
开发者ID:html-shell,项目名称:mozbuild,代码行数:52,代码来源:mach_commands.py


示例14: main

def main():
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('--port', type=int, default=8000,
                        help='Port on which to listen')
    commandline.add_logging_group(parser)
    args = parser.parse_args()

    logging.basicConfig(level=logging.INFO)

    app.logger.info('starting REST listener on port %d' % args.port)
    app.run(host="0.0.0.0", port=args.port, debug=False)
开发者ID:Nephyrin,项目名称:bzexport,代码行数:13,代码来源:autoland_rest.py


示例15: main

def main():
    parser = get_parser()
    commandline.add_logging_group(parser)

    args = parser.parse_args()

    logger = commandline.setup_logging("structured-example", args, {"raw": sys.stdout})

    runner = TestRunner()
    try:
        runner.run()
    except:
        logger.critical("Error during test run:\n%s" % traceback.format_exc())
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:13,代码来源:structured_example.py


示例16: test_logging_defaultlevel

    def test_logging_defaultlevel(self):
        parser = argparse.ArgumentParser()
        commandline.add_logging_group(parser)

        args = parser.parse_args(["--log-tbpl=%s" % self.logfile.name])
        logger = commandline.setup_logging("test_fmtopts", args, {})
        logger.info("INFO message")
        logger.debug("DEBUG message")
        logger.error("ERROR message")
        # The debug level is not logged by default.
        self.assertEqual(["INFO message",
                          "ERROR message"],
                         self.loglines)
开发者ID:mlasak,项目名称:gecko-dev,代码行数:13,代码来源:test_structured.py


示例17: test_logging_debuglevel

 def test_logging_debuglevel(self):
     parser = argparse.ArgumentParser()
     commandline.add_logging_group(parser)
     args = parser.parse_args(["--log-tbpl=%s" % self.logfile.name, "--log-tbpl-level=debug"])
     logger = commandline.setup_logging("test_fmtopts", args, {})
     logger.info("INFO message")
     logger.debug("DEBUG message")
     logger.error("ERROR message")
     # Requesting a lower log level than default works as expected.
     self.assertEqual(["INFO message",
                       "DEBUG message",
                       "ERROR message"],
                      self.loglines)
开发者ID:mlasak,项目名称:gecko-dev,代码行数:13,代码来源:test_structured.py


示例18: cli

def cli():
    global logger
    global webapi_results
    global webapi_results_embed_app

    reload(sys)
    sys.setdefaultencoding('utf-8')

    parser = argparse.ArgumentParser()
    parser.add_argument("--version",
                        help="version of FxOS under test",
                        default="2.2",
                        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("--html-result-file",
                        help="absolute file path to store the resulting html.",
                        action="store")
    parser.add_argument("--generate-reference",
                        help="Generate expected result files",
                        action="store_true")
    parser.add_argument('-p', "--device-profile", action="store",  type=os.path.abspath,
                        help="specify the device profile file path which could include skipped test case information")
    commandline.add_logging_group(parser)

    args = parser.parse_args()

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

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

    try:
        _run(args, logger)
    except:
        logger.critical(traceback.format_exc())
        raise
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:49,代码来源:cert.py


示例19: test_limit_formatters

 def test_limit_formatters(self):
     parser = argparse.ArgumentParser()
     commandline.add_logging_group(parser, include_formatters=['raw'])
     other_formatters = [fmt for fmt in commandline.log_formatters
                         if fmt != 'raw']
     # check that every formatter except raw is not present
     for fmt in other_formatters:
         with self.assertRaises(SystemExit):
             parser.parse_args(["--log-%s=-" % fmt])
         with self.assertRaises(SystemExit):
             parser.parse_args(["--log-%s-level=error" % fmt])
     # raw is still ok
     args = parser.parse_args(["--log-raw=-"])
     logger = commandline.setup_logging("test_setup_logging2", args, {})
     self.assertEqual(len(logger.handlers), 1)
开发者ID:AlanWasTaken,项目名称:servo,代码行数:15,代码来源:test_structured.py


示例20: 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
    next_mozreview_update = datetime.datetime.now()
    while True:
        try:
            handle_pending_mozreview_pullrequests(logger, dbconn)
            handle_pending_transplants(logger, dbconn)
            handle_pending_github_updates(logger, dbconn)

            # TODO: In normal configuration, all updates will be posted to the
            # same MozReview instance, so we don't bother tracking failure to
            # post for individual urls. In the future, we might need to
            # support this.
            if datetime.datetime.now() > next_mozreview_update:
                ok = handle_pending_mozreview_updates(logger, dbconn)
                if ok:
                    next_mozreview_update += datetime.timedelta(seconds=1)
                else:
                    next_mozreview_update += MOZREVIEW_RETRY_DELAY

            time.sleep(0.1)
        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:frostytear,项目名称:version-control-tools,代码行数:47,代码来源:autoland.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python commandline.setup_logging函数代码示例发布时间:2022-05-27
下一篇:
Python structured.get_default_logger函数代码示例发布时间: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