meraki / automation-scripts

MIT License
391 stars 198 forks source link

Issue with csv writing #34

Closed pblais-bowlero closed 2 years ago

pblais-bowlero commented 2 years ago

Receive the following error below when running the report_statuses.py. I tried adding the lines in the fieldnames but it still comes back with the same error. Please advise. I need to see status of my MX applicances by Monday morning EST so I can upgrade them.

Thanks,

Paul

2022-07-15 12:27:56 meraki: INFO > organizations, getOrganizationNetworks; page 1 - 200 OK Traceback (most recent call last): File "C:\Users\pblais\OneDrive\OneDrive - Bowlero Corp\Desktop\Meraki-uplink\report-status\report_statuses.py", line 147, in main() File "C:\Users\pblais\OneDrive\OneDrive - Bowlero Corp\Desktop\Meraki-uplink\report-status\report_statuses.py", line 143, in main csv_writer.writerow(status) File "C:\Users\pblais\AppData\Local\Programs\Python\Python39\lib\csv.py", line 154, in writerow return self.writer.writerow(self._dict_to_list(rowdict)) File "C:\Users\pblais\AppData\Local\Programs\Python\Python39\lib\csv.py", line 149, in _dict_to_list raise ValueError("dict contains fields not in fieldnames: " ValueError: dict contains fields not in fieldnames: 'components', 'productType', 'model', 'tags'

mpapazog commented 2 years ago

I added some missing items to the field_names variables, and now the script does not throw any more errors in my lab. Please test if it works for you as well.

pblais-bowlero commented 2 years ago

Works like a charm now. Thanks for the quick response and resolution. One thing that I would say you may want to incorporate is the environment variable for the key so you don't have to use the actual key in the script. You can use the MERAKI_DASHBOARD_API_KEY format which will call your environment variable. Thanks again.

mpapazog commented 2 years ago

Uploaded a new version of the script, which will now try to load an API key from env var MERAKI_DASHBOARD_API_KEY, if parameter -k is omitted. Please check if this version does what you need.

pblais-bowlero commented 2 years ago

That rocks!!!! I just tested your environment variable with omitting the API key and the environment variable worked perfectly. Thanks for doing that so quickly.