def check_status(settings, instance_id):
    """
    Check the build status semaphore for an instance
    """
    # Get s3 bucket & key
    bucket, key = open_s3(settings, settings['asset_bucket'], 
                          "%s._cc_" % instance_id)

    if key.exists() and key.get_contents_as_string() == 'running':
        return True
    else: return False
def set_status(settings, instance_id):
    """
    Set a instance build status semaphore in s3
    """
    # Get s3 bucket & key
    bucket, key = open_s3(settings, settings['asset_bucket'], 
                          "%s._cc_" % instance_id)

    # set plain text headers
    headers = {'Content-Type':'text/plain'}

    try:
        key.set_contents_from_string('running', headers, replace=True)
    except boto.s3.connection.S3CreateError, e:
        print "Failed: %s" % e