diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2008-02-05 15:51:11 -0500 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2008-02-05 15:51:11 -0500 |
commit | 51c00fd6c8bd7ef703f260e7d94ac43f4294624b (patch) | |
tree | f2eff508630a2fdb69dfe9dd8b748d2afc22710c /func/utils.py | |
parent | 8c7114e9c59419fb1ecce075e56c34e0198b8228 (diff) | |
download | third_party-func-51c00fd6c8bd7ef703f260e7d94ac43f4294624b.tar.gz third_party-func-51c00fd6c8bd7ef703f260e7d94ac43f4294624b.tar.xz third_party-func-51c00fd6c8bd7ef703f260e7d94ac43f4294624b.zip |
Make hostname detection code shared.
Diffstat (limited to 'func/utils.py')
-rwxr-xr-x | func/utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
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 |