示例#1
0
文件: cli.py 项目: vmon/ooni-probe
def setupCollector(global_options, collector_client):
    from ooni.backend_client import CollectorClient

    if global_options['collector']:
        collector_client = CollectorClient(global_options['collector'])
    elif config.reports.get('collector', None) is not None:
        collector_client = CollectorClient(config.reports['collector'])
    if not collector_client.isSupported():
        raise errors.CollectorUnsupported
    return collector_client
示例#2
0
文件: cli.py 项目: ivilata/ooni-probe
def setupCollector(global_options, collector_client):
    from ooni.backend_client import CollectorClient

    if global_options['collector']:
        collector_client = CollectorClient(global_options['collector'])
    elif config.reports.get('collector', None) is not None:
        collector_client = CollectorClient(config.reports['collector'])
    if not collector_client.isSupported():
        raise errors.CollectorUnsupported
    return collector_client
示例#3
0
def get_reachable_collector(collector_address, collector_alternate,
                            preferred_backend):
    for collector_settings in sort_addresses_by_priority(
            collector_address, collector_alternate, preferred_backend):
        collector = CollectorClient(settings=collector_settings)
        if not collector.isSupported():
            log.err(
                "Unsupported %s collector %s" %
                (collector_settings['type'], collector_settings['address']))
            continue
        reachable = yield collector.isReachable()
        if not reachable:
            log.err(
                "Unreachable %s collector %s" %
                (collector_settings['type'], collector_settings['address']))
            continue
        defer.returnValue(collector)

    raise e.NoReachableCollectors