Example #1
0
def ooniprobe(reactor):
    from ooni.ui.cli import runWithDaemonDirector, runWithDirector
    from ooni.ui.cli import setupGlobalOptions, initializeOoniprobe
    from ooni.settings import config

    global_options = setupGlobalOptions(logging=True, start_tor=True,
                                        check_incoherences=True)
    if global_options['info']:
        config.log_info()
        return defer.succeed(None)

    if global_options['queue']:
        return runWithDaemonDirector(global_options)

    if global_options['web-ui']:
        from ooni.settings import config
        from ooni.scripts.ooniprobe_agent import status_agent, start_agent
        if status_agent() != 0:
            p = Process(target=start_agent)
            p.start()
            p.join()
            print("Started ooniprobe-agent")
        webbrowser.open_new(config.web_ui_url)
        return defer.succeed(None)

    if global_options['initialize']:
        initializeOoniprobe(global_options)
        return defer.succeed(None)

    return runWithDirector(global_options)
Example #2
0
def ooniprobe(reactor):
    from ooni.ui.cli import runWithDaemonDirector, runWithDirector
    from ooni.ui.cli import setupGlobalOptions, initializeOoniprobe
    from ooni.settings import config

    global_options = setupGlobalOptions(logging=True,
                                        start_tor=True,
                                        check_incoherences=True)
    if global_options['info']:
        config.log_info()
        return defer.succeed(None)

    if global_options['queue']:
        return runWithDaemonDirector(global_options)

    if global_options['web-ui']:
        from ooni.settings import config
        from ooni.scripts.ooniprobe_agent import status_agent, start_agent
        if status_agent() != 0:
            p = Process(target=start_agent)
            p.start()
            p.join()
            print("Started ooniprobe-agent")
        webbrowser.open_new(config.web_ui_url)
        return defer.succeed(None)

    if global_options['initialize']:
        initializeOoniprobe(global_options)
        return defer.succeed(None)

    return runWithDirector(global_options)
Example #3
0
    def run_helper(self, test_name, nettest_args, verify_function, ooni_args=()):
        output_file = os.path.abspath('test_report.njson')
        self.filenames.append(output_file)
        oldargv = sys.argv
        sys.argv = ['']
        sys.argv.extend(ooni_args)
        sys.argv.extend(['-n', '-o', output_file, test_name])
        sys.argv.extend(nettest_args)
        global_options = setupGlobalOptions(False, False, False)

        config.tor.socks_port = 9050
        config.advanced.start_tor = False
        config.tor.control_port = None
        config.advanced.debug = True

        yield runWithDirector(global_options,
                              create_input_store=False)
        with open(output_file) as f:
            entries = map(json.loads, f)
            first_entry = entries[0]
            try:
                test_keys = entries[0]['test_keys']
            except StopIteration:
                raise Exception("Missing entry in report")
        verify_header(first_entry)
        verify_entry(first_entry)
        verify_function(test_keys)
        sys.argv = oldargv
Example #4
0
    def run_helper(self,
                   test_name,
                   nettest_args,
                   verify_function,
                   ooni_args=()):
        output_file = os.path.abspath('test_report.njson')
        self.filenames.append(output_file)
        oldargv = sys.argv
        sys.argv = ['']
        sys.argv.extend(ooni_args)
        sys.argv.extend(['-n', '-o', output_file, test_name])
        sys.argv.extend(nettest_args)
        global_options = setupGlobalOptions(False, False, False)

        config.tor.socks_port = 9050
        config.advanced.start_tor = False
        config.tor.control_port = None
        config.advanced.debug = True

        yield runWithDirector(global_options, create_input_store=False)
        with open(output_file) as f:
            entries = map(json.loads, f)
            first_entry = entries[0]
            try:
                test_keys = entries[0]['test_keys']
            except StopIteration:
                raise Exception("Missing entry in report")
        verify_header(first_entry)
        verify_entry(first_entry)
        verify_function(test_keys)
        sys.argv = oldargv