dwighthubbard / python-dlipower

Python modules to manage Digital Loggers Web Power Switch
Other
54 stars 35 forks source link

Debug output line causes AttributeError #55

Open myronwalkersonos opened 2 years ago

myronwalkersonos commented 2 years ago

This line of code is causing an attibute error.

logger.debug('Response code: %s', request.status_code)

https://github.com/dwighthubbard/python-dlipower/blob/6d6c961a3da1059c42ff4abc0114b266edaf1028/dlipower/dlipower.py#L429

request is not guaranteed to have a value and so if the request fails, the code is trying to get the 'status_code' attribute of None which will result in an AttributeError exception being raised.

Example:

AttributeError: 'NoneType' object has no attribute 'status_code'