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

Add get_host_name method #75

Merged
merged 2 commits into from
Nov 12, 2020
Merged

Add get_host_name method #75

merged 2 commits into from
Nov 12, 2020

Conversation

marvinjuette
Copy link
Contributor

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.

Add get_host_name method for easy access of the device name.
"""
Returns a String with the host_name of the device with the given mac_address
"""
host = list
Copy link
Owner

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.

host = list
try:
host = self.get_specific_host_entry(mac_address)
except:
Copy link
Owner

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.

Copy link
Owner

@kbr kbr left a 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?

@kbr
Copy link
Owner

kbr commented Oct 27, 2020

@marvinjuette you can boild down the code to

def get_host_name(self, mac_address):
    return self.get_specific_host_entry(mac_address)['NewHostName']

and leave the error-handling to the caller, who can decide what to do. Does this code return meaningfull devicenames where the other service get_generic_host_entry just returns generic names? I've not tested this so far.

@marvinjuette
Copy link
Contributor Author

@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
@marvinjuette
Copy link
Contributor Author

@kbr updated my code.

@kbr kbr merged commit 9c79afe into kbr:master Nov 12, 2020
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