Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unknown sensors #31

Merged
merged 4 commits into from
Apr 23, 2023
Merged

Conversation

jehendeoff
Copy link
Contributor

My computer is weird, my system doesn't use eth0 for the ethernet and the temperature sensor given by the command sensor isn't recognized by rust.

So I edited the code to give the user a list of available sensor/interface when the default one doesn't works.

On my computer `sensors` wive me a list of sensors but with names that the sysinfo library doesn't recognize, so I decided to make a fix for it.

if the sensor isn't found in sysinfo, instead of giving an error everytime, only throw 1 error and a list of found sensors (on my computer it was `nct6797 CPUTIN` which `sensors` did not lists under that name)
When the specified network interface isn't found, it gives the user a list of all the recognized interfaces
warn!("couldn't find sensor `{}`", self.sensor_name);
Ok(())
})?;
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This result is unused. That could lead to it having no effect. Can you fix that? You can use cargo clippy to find mistakes like these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I will try to fix that, it's my first time in rust so there's a lot that I have to learn

).is_none(){
warn!("Couldn't find network interface `{}`", net_interface_name);
info!("Instead, found those interfaces:");
for (interface_name, _unused) in sys.networks() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better would be for (interface_name, _) in sys.networks()

@jehendeoff
Copy link
Contributor Author

I think I modified the code to something you could like, please let me know if there are other things that bother you

@not-jan not-jan merged commit f59b318 into not-jan:master Apr 23, 2023
@not-jan
Copy link
Owner

not-jan commented Apr 23, 2023

Looks good, thank you!

@jehendeoff jehendeoff deleted the fix_unknown_sensors branch April 24, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants