chg: [tools extract_cryptocurrency] new input: list of addresses to extract

This commit is contained in:
Terrtia 2021-04-28 11:29:48 +02:00
parent 3d620a6548
commit 00c7ec2d91
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
2 changed files with 12 additions and 4 deletions

View file

@ -132,6 +132,11 @@ class Correlation(object):
stop = start + nb_elem -1 stop = start + nb_elem -1
return r_serv_metadata.zrange(f'{self.correlation_name}_all:{subtype}', start, stop) return r_serv_metadata.zrange(f'{self.correlation_name}_all:{subtype}', start, stop)
def paginate_list(self, obj_list, nb_elem=50, page=1):
start = (page - 1) * nb_elem
stop = start + nb_elem
return obj_list[start:stop]
def get_all_correlation_types(self): def get_all_correlation_types(self):
''' '''
Gel all correlation types Gel all correlation types

View file

@ -34,8 +34,6 @@ def sanitise_nb_max_nodes(nb_max_nodes):
return nb_max_nodes return nb_max_nodes
def get_object_correlation_json(correlation_id, subtype, max_nodes): def get_object_correlation_json(correlation_id, subtype, max_nodes):
max_nodes = sanitise_nb_max_nodes(max_nodes)
object_type = 'cryptocurrency' object_type = 'cryptocurrency'
max_nodes = sanitise_nb_max_nodes(max_nodes) max_nodes = sanitise_nb_max_nodes(max_nodes)
@ -51,7 +49,8 @@ def get_object_correlation_json(correlation_id, subtype, max_nodes):
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Trigger backgroud update') parser = argparse.ArgumentParser(description='Trigger backgroud update')
parser.add_argument('-t', '--type', help='Cryptocurrency type (bitcoin, bitcoin-cash, etherum, litecoin, monero, dash, zcash)', type=str, dest='type', required=True, default=None) parser.add_argument('-t', '--type', help='Cryptocurrency type (bitcoin, bitcoin-cash, ethereum, litecoin, monero, dash, zcash)', type=str, dest='type', required=True, default=None)
parser.add_argument('-a', '--address', help='Cryptocurrency addresses', type=str, dest='address', required=True, default=None, nargs="*")
parser.add_argument('-p', '--page',help='page number' , type=int, default=1, dest='page') parser.add_argument('-p', '--page',help='page number' , type=int, default=1, dest='page')
parser.add_argument('-n', '--nb',help='number of addresses by page' , type=int, default=50, dest='nb_elem') parser.add_argument('-n', '--nb',help='number of addresses by page' , type=int, default=50, dest='nb_elem')
parser.add_argument('--node' ,help='correlation graph: max number of nodes' , type=int, default=50, dest='max_nodes') parser.add_argument('--node' ,help='correlation graph: max number of nodes' , type=int, default=50, dest='max_nodes')
@ -67,7 +66,11 @@ if __name__ == '__main__':
max_nodes = sanitise_int(args.max_nodes, 300) max_nodes = sanitise_int(args.max_nodes, 300)
dict_json = {} dict_json = {}
for address in Cryptocurrency.cryptocurrency.get_all_correlations_by_subtype_pagination(subtype, nb_elem=nb_elem, page=page): if args.address:
l_addresse = Cryptocurrency.cryptocurrency.paginate_list(args.address, nb_elem=nb_elem, page=page)
else:
l_addresse = Cryptocurrency.cryptocurrency.get_all_correlations_by_subtype_pagination(subtype, nb_elem=nb_elem, page=page)
for address in l_addresse:
dict_json[address] = get_object_correlation_json(address, subtype, max_nodes) dict_json[address] = get_object_correlation_json(address, subtype, max_nodes)
print(json.dumps(dict_json)) print(json.dumps(dict_json))