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)
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)
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)