예제 #1
0
def run(args=sys.argv[1:]):
    options = Options()
    try:
        options.parseOptions(args)
    except Exception as exc:
        print("Error: %s" % exc)
        print(options)
        sys.exit(2)
    config.global_options = dict(options)
    config.set_paths()
    config.read_config_file()

    if options['default-collector']:
        options['bouncer'] = CANONICAL_BOUNCER_ONION

    if options['command'] == "upload" and options['report_file']:
        tor_check()
        return tool.upload(options['report_file'],
                           options['collector'],
                           options['bouncer'])
    elif options['command'] == "upload":
        tor_check()
        return tool.upload_all(options['collector'],
                               options['bouncer'])
    elif options['command'] == "status":
        return tool.status()
    else:
        print(options)
예제 #2
0
def run():
    config.read_config_file()
    options = parse_options()
    if options['command'] == "upload" and options['report_file']:
        return tool.upload(options['report_file'],
                           options['collector'],
                           options['bouncer'])
    elif options['command'] == "upload":
        return tool.upload_all(options['collector'],
                               options['bouncer'])
    elif options['command'] == "status":
        return tool.status()
예제 #3
0
파일: cli.py 프로젝트: kudrom/ooni-probe
def run():
    config.read_config_file()
    options = Options()
    try:
        options.parseOptions()
    except Exception as exc:
        print("Error: %s" % exc)
        print(options)
        sys.exit(2)
    if options['command'] == "upload" and options['report_file']:
        tor_check()
        return tool.upload(options['report_file'],
                           options['collector'],
                           options['bouncer'])
    elif options['command'] == "upload":
        tor_check()
        return tool.upload_all(options['collector'],
                               options['bouncer'])
    elif options['command'] == "status":
        return tool.status()
    else:
        print(options)
예제 #4
0
    def test_tool_upload(self, mock_oonib_reporter, mock_oonib_report_log,
                         mock_collector_client):

        mock_oonib_reporter_i = mock_oonib_reporter.return_value
        mock_oonib_reporter_i.createReport.return_value = defer.succeed("fake_id")
        mock_oonib_reporter_i.writeReportEntry.return_value = defer.succeed(True)
        mock_oonib_reporter_i.finish.return_value = defer.succeed(True)

        mock_oonib_report_log_i = mock_oonib_report_log.return_value
        mock_oonib_report_log_i.created.return_value = defer.succeed(True)
        mock_oonib_report_log_i.closed.return_value = defer.succeed(True)

        report_name = "dummy_report.yaml"
        self._create_reporting_yaml(report_name)
        self._write_dummy_report(report_name)

        d = tool.upload(report_name)
        @d.addCallback
        def cb(result):
            mock_oonib_reporter_i.writeReportEntry.assert_called_with(
                {"spam": "ham"}
            )
        return d