Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Tries to determine the hostname and the IP of the local host.
Returns name and IP if successfull, otherwise both will be None.

        def getHostNameIP():
	"""Tries to determine the hostname and the IP of the local host.
	Returns name and IP if successfull, otherwise both will be None.
	"""
	hn, al, ip = socket.gethostbyaddr(socket.gethostname())
	if len(ip) > 1:
		print "Multiple IPs per interface detected ('" + str(ip) + "').\r\nPlease specify the desired IP in Config.py"
		return None, None
	else:
		hn_new = socket.getfqdn(hn)
		num = hn_new.count(".")
		if num < 2:
			print "Hostname detection failed ('" + str(hn_new) + "' does not contain two dots).\r\nPlease specify the desired full qualified domain hostname in Config.py"
			return None, None
		else:
			return hn_new, ip[0]
        


src/s/f/sftf-HEAD/SFTF.py   sftf(Download)
from TestResult import TestResult, getResultString
import sys, os, getopt, traceback, socket, py_compile
from NetworkEventHandler import getHostNameIP, getFQDN, checkIPv6Support
 
def resToCol(res):
		sys.exit(1)
	if (Config.LOCAL_IP == "") and (Config.LOCAL_HOSTNAME == ""):
		hn, ip = getHostNameIP()
		if (hn is None) or (ip is None):
			sys.exit(1)