# Path: loadsbroker/aws.py
# AWS_REGIONS = (
#     # "ap-northeast-1", "ap-southeast-1", "ap-southeast-2",  # speeding up
#     "eu-west-1",
#     # "sa-east-1",   # this one times out
#     "us-east-1",
#     "us-west-1",
#     "us-west-2"
# )


from io import StringIO
from functools import wraps
from loadsbroker.aws import AWS_REGIONS
    from boto.ec2 import connect_to_region
import sys
import subprocess
import requests
import time
import os
import boto
    import logging


def _start_daemon(cmd, port):
    daemon = subprocess.Popen(cmd, shell=True,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)

    # wait for the fake docker daemon to be ready
    starting = time.time()
    started = False

    errors = []

    while time.time() - starting < 2:
        try:
            requests.get('http://127.0.0.1:%d' % port, timeout=.1)
            started = True
            break
        except Exception as exc:
            errors.append(exc)
            time.sleep(.1)

    if not started:
        for exc in errors:
            print(str(exc))
            if hasattr(exc, 'response') and exc.response is not None:
                print('status: %d' % exc.response.status_code)
                print(exc.response.content)

        print('Could not start the daemon')

# Path: loadsbroker/aws.py
# AWS_REGIONS = (
#     # "ap-northeast-1", "ap-southeast-1", "ap-southeast-2",  # speeding up
#     "eu-west-1",
#     # "sa-east-1",   # this one times out
#     "us-east-1",
#     "us-west-1",
#     "us-west-2"
# )


# Path: loadsbroker/tests/util.py
from io import StringIO
from functools import wraps
from loadsbroker.aws import AWS_REGIONS
    from boto.ec2 import connect_to_region
import sys
import subprocess
import requests
import time
import os
import boto
    import logging



def _start_daemon(cmd, port):
    daemon = subprocess.Popen(cmd, shell=True,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)

    # wait for the fake docker daemon to be ready
    starting = time.time()
    started = False

    errors = []

    while time.time() - starting < 2:
        try:
            requests.get('http://127.0.0.1:%d' % port, timeout=.1)
            started = True
            break
        except Exception as exc:
            errors.append(exc)
            time.sleep(.1)

    if not started:
        for exc in errors:
            print(str(exc))
            if hasattr(exc, 'response') and exc.response is not None:
                print('status: %d' % exc.response.status_code)
                print(exc.response.content)

        print('Could not start the daemon')

        try: