-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add get_host_name method #75
Conversation
Add get_host_name method for easy access of the device name.
fritzconnection/lib/fritzhosts.py
Outdated
""" | ||
Returns a String with the host_name of the device with the given mac_address | ||
""" | ||
host = list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is not necessary. It just binds the list callable to a new label never used later on.
fritzconnection/lib/fritzhosts.py
Outdated
host = list | ||
try: | ||
host = self.get_specific_host_entry(mac_address) | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please never use a 'naked' except, because it will be hard to find bugs later on. Explicitly catch just the error types you expect and are able to handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank you very much for the first pull request. The code has some issues I have commented. May I ask what kind of error you expect by calling get_specific_host_entry
beside an invalid mac_address
?
@marvinjuette you can boild down the code to
and leave the error-handling to the caller, who can decide what to do. Does this code return meaningfull devicenames where the other service |
@kbr I created this method because generic_host_entry uses the index of the host in order to display all the data. And I want to get the hostname just from a mac. |
Changed to fit request for original repo
@kbr updated my code. |
Add get_host_name method for easy access of the device name.
Known Issues:
Sometimes get_specifiy_host_entry returns nothing and host is empty, but this occurred only when the repeaters mac was checked.
But I already created an issue ( #74 ) because of some problems with repeaters.