It's a type of Planche
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import socket
  4. def get_hostname(host_or_ip):
  5. host_or_ip = socket.getfqdn(host_or_ip)
  6. try:
  7. return socket.gethostbyaddr(host_or_ip)[0]
  8. except socket.gaierror:
  9. return False
  10. def get_aliases(host_or_ip):
  11. host_or_ip = socket.getfqdn(host_or_ip)
  12. try:
  13. return socket.gethostbyaddr(host_or_ip)[1]
  14. except socket.gaierror:
  15. return False
  16. def get_ip_addrs(host_or_ip):
  17. host_or_ip = socket.getfqdn(host_or_ip)
  18. try:
  19. return socket.gethostbyaddr(host_or_ip)[2]
  20. except socket.gaierror:
  21. return False