Device metrics update with location update#145
Conversation
…lude optional location data - Updated README to reflect new CSV and JSON output formats and added optional AP floorplan location data. - Refactored account_credentials.yaml to unify credential structure. - Modified device_metrics_export.py to fetch and process device location data, including new command line options for output formats. - Updated requirements.txt to use pycentral version 2.0a22. - Enhanced utils.py with functions to derive site IDs and fetch device locations.
… in outputs based on command line arguments
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Collin-Koss
left a comment
There was a problem hiding this comment.
Verified script works with new features on a fresh install. Created a floorplan and placed device to verify data is getting generated properly into json and csv files. json cli flags working. Suggest small improvement to validate valid json files. Currently an invalid file name results in a traceback error. Everything else looks good.
| jr[column] = None if value == "" else value | ||
| json_rows.append(jr) | ||
|
|
||
| with open(json_path, "w", encoding="utf-8") as jf: |
There was a problem hiding this comment.
Add a handler to check for compatible json files. Currently the script will error with a traceback if an incompatible value is passed to --output-json.
ex when I accidentally added an extra character:
(central-python-workflows) PS C:\Users\koss\Projects\central-python-workflows\central-python-workflows\device-metrics-export> python device_metrics_export.py -c .\account_credentials.yaml --output-json output.json> --include-floorplan --include-raw-location
Traceback (most recent call last):
File "C:\Users\koss\Projects\central-python-workflows\central-python-workflows\device-metrics-export\device_metrics_export.py", line 245, in
main()
File "C:\Users\koss\Projects\central-python-workflows\central-python-workflows\device-metrics-export\device_metrics_export.py", line 153, in main
with open(json_path, "w", encoding="utf-8") as jf:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument: 'output.json>'
The update improves the device metrics export workflow by adding support for JSON output and optional location data. It unifies the credential structure, updates dependencies, and modifies the export script to handle new command line options for output formats. The README reflects these changes, ensuring users are informed about the new features.