Open
Description
Overview
Planning to tidy up the codebase and also take the opportunity to implement some new features 😀. The end goal is to enable the script to also function as a library (rather than only a CLI interface), and to improve maintainablility of the overall codebase.
The project will remain a single python file with no dependencies on external packages, and all of the existing functionality will remain.
Any suggestions/changes/feedback would be much appreciated!
Core Changes
- Replace the 'web' function with Python's urllib
- Create Session class to handle logging in/out & SNMP-over-HTTP requests
- Refactor all classes to inherit a new base class
'APIRequest'Edit: 'RouterSessionClientBase' - Create Output class to handle formatting the output in the command line
- Custom session exceptions - e.g. login failed
- User input exception - allow an user to input text if running as CLI
- All global variables removed (except version)
Documentation
- Custom session exceptions
- User input exception
New Features and minor changes
- Check if a user is already logged in
- Add 'is ethernet/wlan' column to clients list
- Include data from the base64-encoded login cookie to the diagnostic output
- Login action now returns HTTP status code 500 if the password is incorrect. Previously this used to be an empty response, could use this to provide a more user-friendly exception.