Use try/except error handling. In this example, when the first network in the org throws an error in the getNetworkApplianceSecurityIntrusion call, the try/except/break will exit the for device in devices loop, which will then make your code skip to the next organization import meraki
import os
API = os.environ.get("API_KEY_FF")
dashboard = meraki.DashboardAPI(API, suppress_logging=True)
to_write = ""
organisations = dashboard.organizations.getOrganizations()
for organisation in organisations:
devices = dashboard.organizations.getOrganizationDevices(organisation["id"], total_pages='all')
for device in devices:
if "MX" in device["model"]:
print(organisation["name"] + "," + device["model"])
try:
ASI = dashboard.appliance.getNetworkApplianceSecurityIntrusion(device["networkId"])
except Exception as e:
print(str(e))
break
for MX in ASI:
to_write = to_write + f'{organisation["name"]},{device["networkId"]},{device["name"]},{ASI["mode"]}\n'
f = open("Get_ASI_MX.csv", "w")
f.write(to_write)
f.close()
... View more