Пример #1
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    try:
        return api.info()
    except RosetteException as e:
        print(e)
Пример #2
0
def run(key, alt_url='https://api.rosette.com/rest/v1/'):
    """ Run the example """
    # Create an API instance
    api = API(user_key=key, service_url=alt_url)

    try:
        return api.info()
    except RosetteException as exception:
        print(exception)
Пример #3
0
def test_retryNum():
    with open(response_file_dir + "info.json", "r") as info_file:
        body = info_file.read()
        httpretty.register_uri(httpretty.GET, "https://api.rosette.com/rest/v1/info",
                               body=body, status=500, content_type="application/json")
    test = API(user_key=None, retries=5)
    try:
        result = test.info()
        assert False
    except RosetteException as e:
        assert e.message == "A retryable network operation has not succeeded after 5 attempts"
        assert e.status == "unknownError"
Пример #4
0
# -*- coding: utf-8 -*-

"""
Example code to call Rosette API to get information such as version and build
"""

import argparse
import pprint

from rosette.api import API

parser = argparse.ArgumentParser(description="Get information about Rosette API")
parser.add_argument("--key", required=True, help="Rosette API key")
parser.add_argument("--service_url", nargs="?", help="Optional user service URL")
args = parser.parse_args()

# Create an API instance
if args.service_url:
    api = API(service_url=args.service_url, user_key=args.key)
else:
    api = API(user_key=args.key)

result = api.info()

pprint.pprint(result)
Пример #5
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    return api.info()
Пример #6
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    return api.info()