示例#1
0
    def get_net_info():
        '''
        Get host information on current machine
        return dictionary of host information
        '''
        import socket
        results = dict()
        try:
            host_infos = socket.gethostbyaddr(socket.gethostname())
            results['hostname'] = host_infos[0]
            results['host_alias'] = ', '.join(host_infos[1])
            results['ip_address_alternate'] = ', '.join(host_infos[2])

            net_util = NetUtils(10)
            results['ip_address'] = net_util.get_host_ip()
        except:
            print('Failed to get net info')
            #print traceback.print_exc()
        return results