<commit_before>import argparse
import json

import digitalocean


def get_ip(name, token):
    # Gets the list of droplets
    response = json.load(digitalocean.do_get("https://api.digitalocean.com/v2/droplets?page=1&per_page=100", token))
    for droplet in response['droplets']:
        if droplet['name'] == name:
            return droplet['networks']['v4'][0]['ip_address']
    raise Exception('Could not find droplet with name %s' % name)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Ontrack Digital Ocean IP')
    parser.add_argument('--name', required=True, help='Digital Ocean droplet name to get the IP for')
    parser.add_argument('--token', required=True, help='Digital Ocean API token')
    _options = parser.parse_args()
    ip = get_ip(_options.name, _options.token)
    print ip<commit_msg>Correction of IP detection for DO droplets<commit_after>import argparse
import json

import digitalocean


def get_ip(name, token):
    # Gets the list of droplets
    response = json.load(digitalocean.do_get("https://api.digitalocean.com/v2/droplets?page=1&per_page=100", token))
    for droplet in response['droplets']:
        if droplet['name'] == name:
            for network in droplet['networks']['v4']:
                if network['type'] == 'public':
                    return network['ip_address']
    raise Exception('Could not find droplet with name %s' % name)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Ontrack Digital Ocean IP')
    parser.add_argument('--name', required=True, help='Digital Ocean droplet name to get the IP for')
    parser.add_argument('--token', required=True, help='Digital Ocean API token')
    _options = parser.parse_args()
    ip = get_ip(_options.name, _options.token)
    print ip
{'fraction_non_alphanumeric': 0.12555555555555556, 'fraction_numerical': 0.007222222222222222, 'mean_word_length': 3.9342465753424656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '230146', 'n_tokens_mistral': 561, 'n_tokens_neox': 523, 'n_words': 146}