Closed rcpeters closed 9 years ago
Thank you very much for the pull request
! :beers:
I've made some comments And unfortunately you broke the build...
Thanks !
Updated. Not sure what "magic int constants" means exactly as I don't normally use python. I assumed you wanted hard coded values to be declared as an class attribute. However I'm also not sure if you where referencing not using =+ augmented method.
There are some more issues I want to have fixed. Cl build passed again - very nice! Yes, with "magic int constants" I've ment the fact that you've just used 10 as a "magic value". With making it a class-member you've gave it a little description - more readability
Some other question: Why do you need this timeout for waiting for your sensor? This never happend to me. Are you facing an issue where the kernel modules are not loaded fast enough to create the slave files under /sys or just when you use the sensor directly after boot?
There are two issues I've fixed.
Okay, cool! But the LOAD_KERNEL_MODULES member is needed for testing on machines where this kernel module is not available. There I do not want to try to load the modules.
Are you sure? If the path W1ThermSensor.BASE_DIRECTORY exist it's doesn't try to load the module.
That's true, but have you seen the tests?
The BASE_DIRECTORY
is mocked there and exists. And you can test without to be superuser, because modprobe
on most linux systems need superuser permissions.
Yes I also modified the test and removed LOAD_KERNEL_MODULES. The test still work without super user permissions.
make tests
nosetests -v -s --with-coverage --cover-erase --cover-inclusive test --cover-package=w1thermsensor
test_core.test_get_available_sensors_no_sensors ... ok
test_core.test_get_available_sensors ... ok
test_core.test_get_available_ds18s20_sensors ... ok
test_core.test_get_available_ds1822_sensors ... ok
test_core.test_get_available_ds18b20_sensors ... ok
test_core.test_init_first_sensor ... ok
test_core.test_init_first_sensor_of_specific_type ... ok
test_core.test_init_specific_sensor ... ok
test_core.test_sensor_temperature_in_C ... ok
test_core.test_sensor_temperature_in_F ... ok
test_core.test_sensor_temperature_in_K ... ok
test_core.test_sensor_all_temperature_units ... ok
test_core.test_sensor_type_name ... ok
test_core.test_no_sensor_found_error ... ok
test_core.test_sensor_not_ready_error ... ok
test_core.test_unsupported_unit_error ... ok
Name Stmts Miss Cover Missing
---------------------------------------------
w1thermsensor 96 5 95% 60, 63-64, 143-144
----------------------------------------------------------------------
Ran 16 tests in 2.106s
OK
Okay, I haven't seen the line if not path.isdir(W1ThermSensor.BASE_DIRECTORY):
I will merge it. Thank's for contribution! :beers:
After a reboot first time loading module fails to init, when the second time it would run. Added some check and retry to make sure the module inits correctly.