From 51c00fd6c8bd7ef703f260e7d94ac43f4294624b Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 5 Feb 2008 15:51:11 -0500 Subject: Make hostname detection code shared. --- func/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'func/utils.py') diff --git a/func/utils.py b/func/utils.py index 1a4abb7..54c9c39 100755 --- a/func/utils.py +++ b/func/utils.py @@ -15,6 +15,7 @@ import string import sys import traceback import xmlrpclib +import socket REMOTE_ERROR = "REMOTE_ERROR" @@ -50,6 +51,15 @@ def nice_exception(etype, evalue, etb): nicestack = string.join(traceback.format_list(traceback.extract_tb(etb))) return [ REMOTE_ERROR, nicetype, str(evalue), nicestack ] +def get_hostname(): + fqdn = socket.getfqdn() + host = socket.gethostname() + if fqdn.find(host) != -1: + return fqdn + else: + return host + + def is_error(result): if type(result) != list: return False -- cgit