Change NameError to AttributeError and default to socket.gethostname()