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

Get hostname in a cross-platform way #117

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

pv2b
Copy link
Contributor

@pv2b pv2b commented Jul 19, 2023

os.uname()[1] only works on Unix-like operating systems (and also truncates the hostname to 8 characters on some systems), socket.gethostname() gets the same data in a better cross-platform way.

In my case this was the only thing I needed to change to get this running on Windows (to collect inventory data)

Reference: https://docs.python.org/3/library/os.html#os.uname

os.uname()[1] only works on Unix-like operating systems, socket.gethostname() gets the same data in a cross-platform way.
@bb-Ricardo
Copy link
Owner

Hi,

Very good point. I haven't tested it on windows but if it works for you and it's the recommended way to query the hostname anyway, then I see no harm.

Will merge as soon.

@bb-Ricardo bb-Ricardo changed the base branch from main to next-release July 20, 2023 19:23
@bb-Ricardo bb-Ricardo merged commit f60938e into bb-Ricardo:next-release Jul 20, 2023
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