Get fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available and `name` was given, it is returned unchanged. If `name` w
(name='')
| 806 | |
| 807 | |
| 808 | def getfqdn(name=''): |
| 809 | """Get fully qualified domain name from name. |
| 810 | |
| 811 | An empty argument is interpreted as meaning the local host. |
| 812 | |
| 813 | First the hostname returned by gethostbyaddr() is checked, then |
| 814 | possibly existing aliases. In case no FQDN is available and `name` |
| 815 | was given, it is returned unchanged. If `name` was empty, '0.0.0.0' or '::', |
| 816 | hostname from gethostname() is returned. |
| 817 | """ |
| 818 | name = name.strip() |
| 819 | if not name or name in ('0.0.0.0', '::'): |
| 820 | name = gethostname() |
| 821 | try: |
| 822 | hostname, aliases, ipaddrs = gethostbyaddr(name) |
| 823 | except error: |
| 824 | pass |
| 825 | else: |
| 826 | aliases.insert(0, hostname) |
| 827 | for name in aliases: |
| 828 | if '.' in name: |
| 829 | break |
| 830 | else: |
| 831 | name = hostname |
| 832 | return name |
| 833 | |
| 834 | |
| 835 | _GLOBAL_DEFAULT_TIMEOUT = object() |
nothing calls this directly
no test coverage detected
searching dependent graphs…