Closed kyrias closed 3 years ago
Preferably if it's possible to detect that something like this is the case it would either return None
, or raise a specific error that could just be ignored. Preferably it would be possible to check whether it is possible to get the value before actually trying to get the value and getting the exception thrown at you though.
Glad to know that some people use this project!
It looks like libsensors only provides an error string, with no way to know if the error is somewhat fatal or not.
One possibility would be to add a method that returns None
in case of error, with no way to get the error description. What's wrong with using a try/except
block, though?
What's wrong is mostly that it's not really clear that you really do need to have it around the get_value calls and such, since it's not documented that it can and will raise exceptions, so code using it isn't properly protected against it.
Is get_value()
called from this project?
https://github.com/enkore/i3pystatus/
https://i3pystatus.readthedocs.io/en/latest/i3pystatus.html#temp
From what I remember, the libsensors documentation is pretty minimal as well and there is no way to know the error cases other than trial and error.
I see two possible actions:
SensorsException
in every wrapper method for a C function that may fail. Currently, only SensorsException
's documentation contains this information.ChipName.get_value_or_none()
method.In any case, i3pystatus will need to be updated.
Yeah. I think any of the solutions would be acceptable, though get_value_or_none
would likely be most useful and userfriendly.
When my intel WiFi NICs are rfkilled sensorsd can't get the temperature anymore it seems, and when my i3 bar tries to get the value for the
sensors.SUBFEATURE_TEMP_INPUT
subfeature I get an exception raised: