<commit_before>import digitalocean
import time
import paramiko


def add_args(parser):
    parser.add_argument("--createvm", help="Create a Digital Ocean VM to execute on", action="store_true")
    parser.add_argument("--listdroplets", help="List available DO Droplets", action="store_true")
    parser.add_argument("--cleanupdroplets", help="Destroys all recon droplets")


def parse_args(args, config):
    if args.listdroplets:
        list_droplets(config)
    if args.createvm:
        droplet = create_vm(config)


def cleanup_droplets(config):
    # build the digital ocean manager object
    manager = digitalocean.Manager(token=config.get("DigitalOcean", "api_key"))

    droplets = manager.get_all_droplets(tag_name="bounty")

    # Delete all droplets that match the tag
    for droplet in droplets:
        droplet.destroy()


def create_vm(config):
    # build the digital ocean manager object
    manager = digitalocean.Manager(token=config.get("DigitalOcean", "api_key"))

    # Create a VM and return a droplet object.
    droplet = digitalocean.Droplet(token=manager.token, name="recon-droplet", region="nyc1", image="ubuntu-16-04-x64",
                                   size_slug="512mb", ssh_keys=manager.get_all_sshkeys(), backups=False)
    print("Creating the droplet...")
    droplet.create()

    print("Waiting for the droplet to be active...")
    # Wait for the DO droplet to become active<commit_msg>fixing cleanupdroplets for DO tools<commit_after>import digitalocean
import time
import paramiko


def add_args(parser):
    parser.add_argument("--createvm", help="Create a Digital Ocean VM to execute on", action="store_true")
    parser.add_argument("--listdroplets", help="List available DO Droplets", action="store_true")
    parser.add_argument("--cleanupdroplets", help="Destroys all recon droplets", action="store_true")


def parse_args(args, config):
    if args.listdroplets:
        list_droplets(config)
    if args.createvm:
        droplet = create_vm(config)
    if args.cleanupdroplets:
        cleanup_droplets(config)


def cleanup_droplets(config):
    list_droplets(config)
    # build the digital ocean manager object
    manager = digitalocean.Manager(token=config.get("DigitalOcean", "api_key"))

    droplets = manager.get_all_droplets(tag_name="bounty")

    # Delete all droplets that match the tag
    for droplet in droplets:
        droplet.destroy()
    list_droplets(config)


def create_vm(config):
    # build the digital ocean manager object
    manager = digitalocean.Manager(token=config.get("DigitalOcean", "api_key"))

    # Create a VM and return a droplet object.
    droplet = digitalocean.Droplet(token=manager.token, name="recon-droplet", region="nyc1", image="ubuntu-16-04-x64",
                                   size_slug="512mb", ssh_keys=manager.get_all_sshkeys(), backups=False)
    print("Creating the droplet...")
    droplet.create()

    print("Waiting for the droplet to be active...")
    # Wait for the DO droplet to become active
{'fraction_non_alphanumeric': 0.10945273631840796, 'fraction_numerical': 0.006633499170812604, 'mean_word_length': 3.8645161290322583, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3070446', 'n_tokens_mistral': 961, 'n_tokens_neox': 873, 'n_words': 229}