Skip to content

error "list indices must be integers or slices, not str" #64

@kafisatz

Description

@kafisatz

Looping over all monitors to get their status I tend to run into the below issue.
Is it possible there is a type issue in your code?

image

my code is roughly

    monitors = api.get_monitors()
    n_monitors = len(monitors)

    cnt_up = 0
    cnt_active = 0

    for monitor in monitors:
        id = monitor["id"]
        name = monitor["name"]
        if monitor["active"]:
            #print(id)
            #print(name)
            cnt_active += 1
            st = 9981 #default value
            
            for n in range(1):
                    st = api.get_monitor_status(id) 
                    if st == 1:
                                    cnt_up += 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions