def getfqdn(name='<STR_LIT>'):
name = name.strip()<EOL>if not name or name == '<STR_LIT>':<EOL><INDENT>name = gethostname()<EOL><DEDENT>try:<EOL><INDENT>hostname, aliases, ipaddrs = gethostbyaddr(name)<EOL><DEDENT>except error:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>aliases.insert(<NUM_LIT:0>, hostname)<EOL>for name in aliases:<EOL><INDENT>if '<STR_LIT:.>' in name:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>name = hostname<EOL><DEDENT><DEDENT>return name<EOL>
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, hostname
    from gethostname() is returned.