示例#1
0
def get_galleries_names_object():
    validate_settings()

    auth_headers = {'app_id': settings.app_id, 'app_key': settings.app_key}

    # response = requests.post(_galleries_list_url, headers=auth_headers)
    response = urlfetch.fetch(url=_galleries_list_url,
                              payload=payload,
                              method=urlfetch.POST,
                              headers=auth_headers)
    json_response = response.json()
    if response.status_code != 200 or 'Errors' in json_response:
        raise exceptions.ServiceRequestError(response.status_code,
                                             json_response, None)

    return json_response['gallery_ids']
示例#2
0
def detect_face(url=None, file=None, additional_arguments={}):
    validate_settings()
    validate_file_and_url_presence(file, url)

    auth_headers = {'app_id': settings.app_id, 'app_key': settings.app_key}
    payload = _build_payload(url, file, additional_arguments)

    # response = requests.post(_detect_base_url, json=payload, headers=auth_headers)
    response = urlfetch.fetch(url=_detect_base_url,
                              payload=payload,
                              method=urlfetch.POST,
                              headers=auth_headers)
    json_response = response.json()
    if response.status_code != 200 or 'Errors' in json_response:
        raise exceptions.ServiceRequestError(response.status_code,
                                             json_response, payload)

    return json_response
示例#3
0
def get_gallery_object(gallery_name):
    validate_settings()
    _validate_gallery_name(gallery_name)

    auth_headers = {'app_id': settings.app_id, 'app_key': settings.app_key}

    payload = {'gallery_name': gallery_name}
    # response = requests.post(_gallery_base_url, json=payload, headers=auth_headers)
    response = urlfetch.fetch(url=_gallery_base_url,
                              payload=payload,
                              method=urlfetch.POST,
                              headers=auth_headers)
    json_response = response.json()
    if response.status_code != 200 or 'Errors' in json_response:
        raise exceptions.ServiceRequestError(response.status_code,
                                             json_response, payload)

    return KairosFaceGallery(gallery_name, json_response['subject_ids'])
示例#4
0
def remove_face(subject_id, gallery_name):
    validate_settings()
    _validate_arguments_presence(gallery_name, subject_id)

    auth_headers = {
        'app_id': settings.app_id,
        'app_key': settings.app_key
    }

    payload = _build_payload(gallery_name, subject_id)

    # response = requests.post(_remove_base_url, json=payload, headers=auth_headers)
    response = urlfetch.fetch(
        url=_remove_base_url,
        payload=payload,
        method=urlfetch.POST,
        headers=auth_headers
    )
    json_response = response.json()
    if response.status_code != 200 or 'Errors' in json_response:
        raise exceptions.ServiceRequestError(response.status_code, json_response, payload)

    return json_response