Beispiel #1
0
def upload_signals_to_amphora(irradiation_amphora_id, signals):

    #upload data to amphora data website
    configuration = Configuration()
    auth_api = amphora_client.AuthenticationApi(
        amphora_client.ApiClient(configuration))
    token_request = amphora_client.TokenRequest(username=os.getenv('username'),
                                                password=os.getenv('password'))

    try:
        # Gets a token
        res = auth_api.authentication_request_token(
            token_request=token_request)
        configuration.api_key["Authorization"] = "Bearer " + res
        # create an instance of the Users API, now with Bearer token
        users_api = amphora_client.UsersApi(
            amphora_client.ApiClient(configuration))
        me = users_api.users_read_self()
        print(me)
    except ApiException as e:
        print("Exception when calling AuthenticationAPI: %s\n" % e)

    amphora_api = amphora_client.AmphoraeApi(
        amphora_client.ApiClient(configuration))

    try:
        print(signals)
        amphora_api.amphorae_signals_upload_signal_batch(
            irradiation_amphora_id, request_body=signals)

    except ApiException as e:
        print("Exception when calling AmphoraeApi: %s\n" % e)
EYCI_dict, ESTLI_dict = get_EYCI_ESTLI_data()

#upload data to amphora data website
configuration = Configuration()
auth_api = amphora_client.AuthenticationApi(
    amphora_client.ApiClient(configuration))
token_request = amphora_client.TokenRequest(username=os.getenv('username'),
                                            password=os.getenv('password'))

try:
    # Gets a token
    res = auth_api.authentication_request_token(token_request=token_request)
    configuration.api_key["Authorization"] = "Bearer " + res
    # create an instance of the Users API, now with Bearer token
    users_api = amphora_client.UsersApi(
        amphora_client.ApiClient(configuration))
    me = users_api.users_read_self()
except ApiException as e:
    print("Exception when calling AuthenticationAPI: %s\n" % e)

amphora_api = amphora_client.AmphoraeApi(
    amphora_client.ApiClient(configuration))

#list of dictionaries with signal values
EYCI_signals = []
ESTLI_signals = []

try:
    for key, value in EYCI_dict.items():
        s = {'t': key, 'price': float(value)}
        EYCI_signals.append(s)