本文整理汇总了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)
示例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)
示例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)