123 except socket.error as socketerror: |
111 except socket.error as socketerror: |
124 print 'Socket Error:', socketerror |
112 print 'Socket Error:', socketerror |
125 return '' |
113 return '' |
126 else: |
114 else: |
127 nhost = None |
115 nhost = None |
128 response = enforce_ascii(response) |
116 response = response.decode('utf-8') |
129 if 'with "=xxx"' in response: |
117 if 'with "=xxx"' in response: |
130 return self.whois(query, hostname, flags, True) |
118 return self.whois(query, hostname, flags, True) |
131 if flags & NICClient.WHOIS_RECURSE and nhost is None: |
119 if flags & NICClient.WHOIS_RECURSE and nhost is None: |
132 nhost = self.findwhois_server(response.decode(), hostname, query) |
120 nhost = self.findwhois_server(response, hostname, query) |
133 if nhost is not None: |
121 if nhost is not None: |
134 response += self.whois(query, nhost, 0) |
122 response += self.whois(query, nhost, 0) |
135 return response.decode() |
123 return response |
136 |
124 |
137 def choose_server(self, domain): |
125 def choose_server(self, domain): |
138 """Choose initial lookup NIC host""" |
126 """Choose initial lookup NIC host""" |
139 if type(domain) is not unicode: |
127 if type(domain) is not unicode: |
140 domain = domain.decode('utf-8').encode('idna') |
128 domain = domain.decode('utf-8').encode('idna') |