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


Python NetTestLoader.usageOptions方法代码示例

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


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

示例1: runWithDirector

# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import usageOptions [as 别名]
def runWithDirector():
    """
    Instance the director, parse command line options and start an ooniprobe
    test!
    """
    global_options = parseOptions()
    config.global_options = global_options
    config.set_paths()
    config.read_config_file()

    log.start(global_options['logfile'])
    
    if config.privacy.includepcap:
        try:
            checkForRoot()
        except errors.InsufficientPrivileges:
             log.err("Insufficient Privileges to capture packets."
                     " See ooniprobe.conf privacy.includepcap") 
             sys.exit(2)

    # contains (test_cases, options, cmd_line_options)
    test_list = []

    director = Director()
    d = director.start()

    if global_options['list']:
        print "# Installed nettests"
        for net_test_id, net_test in director.netTests.items():
            print "* %s (%s/%s)" % (net_test['name'],
                                    net_test['category'], 
                                    net_test['id'])
            print "  %s" % net_test['description']

        sys.exit(0)

    #XXX: This should mean no bouncer either!
    if global_options['no-collector']:
        log.msg("Not reporting using a collector")
        collector = global_options['collector'] = None
        global_options['bouncer'] = None

    deck = Deck()
    deck.bouncer = global_options['bouncer']

    try:
        if global_options['testdeck']:
            deck.loadDeck(global_options['testdeck'])
        else:
            log.debug("No test deck detected")
            test_file = nettest_to_path(global_options['test_file'])
            net_test_loader = NetTestLoader(global_options['subargs'],
                    test_file=test_file)
            deck.insert(net_test_loader)
    except errors.MissingRequiredOption, option_name:
        log.err('Missing required option: "%s"' % option_name)
        print net_test_loader.usageOptions().getUsage()
        sys.exit(2)
开发者ID:WheresAlice,项目名称:ooni-probe,代码行数:60,代码来源:oonicli.py

示例2: runWithDirector

# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import usageOptions [as 别名]
def runWithDirector():
    """
    Instance the director, parse command line options and start an ooniprobe
    test!
    """
    global_options = parseOptions()
    config.global_options = global_options
    config.set_paths()
    config.read_config_file()

    log.start(global_options["logfile"])

    if config.privacy.includepcap:
        try:
            checkForRoot()
        except errors.InsufficientPrivileges:
            log.err("Insufficient Privileges to capture packets." " See ooniprobe.conf privacy.includepcap")
            sys.exit(2)

    # contains (test_cases, options, cmd_line_options)
    test_list = []

    director = Director()
    d = director.start()

    # XXX: This should mean no bouncer either!
    if global_options["no-collector"]:
        log.msg("Not reporting using a collector")
        collector = global_options["collector"] = None
        global_options["bouncer"] = None

    deck = Deck()
    deck.bouncer = global_options["bouncer"]

    try:
        if global_options["testdeck"]:
            deck.loadDeck(global_options["testdeck"])
        else:
            log.debug("No test deck detected")
            test_file = nettest_to_path(global_options["test_file"])
            net_test_loader = NetTestLoader(
                global_options["subargs"], test_file=test_file, global_options=global_options
            )
            deck.insert(net_test_loader)
    except errors.MissingRequiredOption, option_name:
        log.err('Missing required option: "%s"' % option_name)
        print net_test_loader.usageOptions().getUsage()
        sys.exit(2)
开发者ID:aagbsn,项目名称:ooni-probe,代码行数:50,代码来源:oonicli.py

示例3: runWithDirector

# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import usageOptions [as 别名]
def runWithDirector(logging=True, start_tor=True):
    """
    Instance the director, parse command line options and start an ooniprobe
    test!
    """
    global_options = parseOptions()
    config.global_options = global_options
    config.set_paths()
    config.read_config_file()
    if not start_tor:
        config.advanced.start_tor = False
    
    if logging:
        log.start(global_options['logfile'])
    
    if config.privacy.includepcap:
        try:
            checkForRoot()
        except errors.InsufficientPrivileges:
             log.err("Insufficient Privileges to capture packets."
                     " See ooniprobe.conf privacy.includepcap") 
             sys.exit(2)

    director = Director()
    if global_options['list']:
        print "# Installed nettests"
        for net_test_id, net_test in director.getNetTests().items():
            print "* %s (%s/%s)" % (net_test['name'],
                                    net_test['category'], 
                                    net_test['id'])
            print "  %s" % net_test['description']

        sys.exit(0)
    
    elif global_options['printdeck']:
        del global_options['printdeck']
        print "# Copy and paste the lines below into a test deck to run the specified test with the specified arguments"
        print yaml.safe_dump([{'options': global_options}]).strip()

        sys.exit(0)

    #XXX: This should mean no bouncer either!
    if global_options['no-collector']:
        log.msg("Not reporting using a collector")
        collector = global_options['collector'] = None
        global_options['bouncer'] = None

    deck = Deck()
    deck.bouncer = global_options['bouncer']
    start_tor = deck.requiresTor
    if global_options['bouncer']:
        start_tor = True
    if global_options['collector']:
        start_tor = True

    try:
        if global_options['testdeck']:
            deck.loadDeck(global_options['testdeck'])
        else:
            log.debug("No test deck detected")
            test_file = nettest_to_path(global_options['test_file'])
            net_test_loader = NetTestLoader(global_options['subargs'],
                    test_file=test_file)
            deck.insert(net_test_loader)
    except errors.MissingRequiredOption, option_name:
        log.err('Missing required option: "%s"' % option_name)
        print net_test_loader.usageOptions().getUsage()
        sys.exit(2)
开发者ID:jacobhaven,项目名称:ooni-probe,代码行数:70,代码来源:oonicli.py


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