python-dlipower
python-dlipower copied to clipboard
Handle Switchs with restricted ports
When a switch does not let the user have access to all ports, the switch can crash trying to access the port. If the port the user has access to has a numeric value greater than the total number of ports it has access to, the script throws an exception.
Instead of naively comparing switch port to switchs length, we iterate all ports and compare number.
Example: Switch grants the user access to Port 5 only. PowerSwitch.repr displays the port correctly. PowerSwitch.status(5) or PowerSwitch.status('name') throws exception stating port is out of range.