trackerv2/server/sendtoindexer.py
def load_local(conf):
    r"""
    Check if Elasticsearch clusters are online and attempt to send data.
    :param dict conf: `configuration['elasticsearch']['offload']`
    """
    with open(conf['index']) as f:
        indexdata = json.load(f)
    for name, cluster in indexdata['clusters'].items():
        success = set()
        for dump in indexdata['dumps'][name]:
            with open(path.join(conf['data folder'], dump), 'rb') as f:
                data = pickle.load(f)
            try:
                if conf['delete old index on reload']:
                    es = Elasticsearch(**cluster)
                    es.indices.delete(
                        data[0]['_index'], ignore_unavailable=True)
                _send_to_cluster(cluster, data)
                success.add(dump)
                remove(path.join(conf['data folder'], dump))
            except BulkIndexError:
                pass
            except TransportError:
                # Cannot reach. Skip
                break
        indexdata['dumps'][name] = list(
            set(indexdata['dumps'][name]) - success)
    with open(conf['index'], 'w') as f:
        json.dump(indexdata, f)
r"""
    Check if Elasticsearch clusters are online and attempt to send data.
    :param dict conf: `configuration['elasticsearch']['offload']`
    
r"""
Check if Elasticsearch clusters are online and attempt to send data.
r " " " Check if Elasticsearch clusters are online and attempt to send data .
def load_local(conf):
    with open(conf['index']) as f:
        indexdata = json.load(f)
    for name, cluster in indexdata['clusters'].items():
        success = set()
        for dump in indexdata['dumps'][name]:
            with open(path.join(conf['data folder'], dump), 'rb') as f:
                data = pickle.load(f)
            try:
                if conf['delete old index on reload']:
                    es = Elasticsearch(**cluster)
                    es.indices.delete(
                        data[0]['_index'], ignore_unavailable=True)
                _send_to_cluster(cluster, data)
                success.add(dump)
                remove(path.join(conf['data folder'], dump))
            except BulkIndexError:
                pass
            except TransportError:
                break
        indexdata['dumps'][name] = list(
            set(indexdata['dumps'][name]) - success)
    with open(conf['index'], 'w') as f:
        json.dump(indexdata, f)
def load_local ( conf ) : with open ( conf [ 'index' ] ) as f : indexdata = json . load ( f ) for name , cluster in indexdata [ 'clusters' ] . items ( ) : success = set ( ) for dump in indexdata [ 'dumps' ] [ name ] : with open ( path . join ( conf [ 'data folder' ] , dump ) , 'rb' ) as f : data = pickle . load ( f ) try : if conf [ 'delete old index on reload' ] : es = Elasticsearch ( ** cluster ) es . indices . delete ( data [ 0 ] [ '_index' ] , ignore_unavailable = True ) _send_to_cluster ( cluster , data ) success . add ( dump ) remove ( path . join ( conf [ 'data folder' ] , dump ) ) except BulkIndexError : pass except TransportError : break indexdata [ 'dumps' ] [ name ] = list ( set ( indexdata [ 'dumps' ] [ name ] ) - success ) with open ( conf [ 'index' ] , 'w' ) as f : json . dump ( indexdata , f )
r"""
Check if Elasticsearch clusters are online and attempt to send data.
r " " " Check if Elasticsearch clusters are online and attempt to send data .
r"""
    Check if Elasticsearch clusters are online and attempt to send data.
    :param dict conf: `configuration['elasticsearch']['offload']`
    """ # Cannot reach. Skip
conf
None