Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
7
Indexable
def update_polling_counts(client, aggregated_values, timestamp):
    table_name = os.getenv(MEGLO_DEVICE_HEALTH_TABLE_NAME, default=None)
    polling_type = os.getenv(LAMBDA_TYPE, default=None)
    current_month_attributes = __get_current_month_ddb_attributes()

    if table_name is None:
        print("Error: Table name is not set. Aborting update.")
        return []

    if not aggregated_values:
        print("Error: Aggregated values are empty. Aborting update.")
        return []

    polling_attribute = current_month_attributes.get(POLLING_COUNT)
    err_attribute = current_month_attributes.get(POLLING_ERROR)
    conn_err_attribute = current_month_attributes.get(CONNECTION_ERROR)

    if None in (polling_attribute, err_attribute, conn_err_attribute):
        print("Error: One or more attributes are missing. Aborting update.")
        return []

    # Rest of your code...

    # If everything is valid, continue with the update
    boto_responses = []
    for data_center in data_centers:
        # ... (rest of your code)

    return boto_responses