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

Open
opened 2024-01-24 13:50:55 +01:00 by kafisatz · 0 comments
kafisatz commented 2024-01-24 13:50:55 +01:00 (Migrated from github.com)

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
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? <img width="1099" alt="image" src="https://github.com/lucasheld/uptime-kuma-api/assets/15026865/2752b8ff-3d7b-4d99-8b77-115f995e021c"> 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 ```
Sign in to join this conversation.
No description provided.