whois/whois.py
branchpython3
changeset 73 644d81a7995b
parent 71 b181f795cc0d
child 81 359baebcf0e8
equal deleted inserted replaced
72:26db2c025614 73:644d81a7995b
   132                 response += self.whois(query, nhost, 0).encode('utf-8')
   132                 response += self.whois(query, nhost, 0).encode('utf-8')
   133             return response.decode()
   133             return response.decode()
   134 
   134 
   135     def choose_server(self, domain):
   135     def choose_server(self, domain):
   136         """Choose initial lookup NIC host"""
   136         """Choose initial lookup NIC host"""
   137         print('domain:', domain)
       
   138         if type(domain) is not str:
   137         if type(domain) is not str:
   139             domain = domain.decode('utf-8').encode('idna').decode('utf-8')
   138             domain = domain.decode('utf-8').encode('idna').decode('utf-8')
   140         if domain.endswith("-NORID"):
   139         if domain.endswith("-NORID"):
   141             return NICClient.NORIDHOST
   140             return NICClient.NORIDHOST
   142         pos = domain.rfind('.')
   141         pos = domain.rfind('.')
   170                 options['country'] + NICClient.QNICHOST_TAIL,
   169                 options['country'] + NICClient.QNICHOST_TAIL,
   171                 flags
   170                 flags
   172             )
   171             )
   173         elif self.use_qnichost:
   172         elif self.use_qnichost:
   174             nichost = self.choose_server(query_arg)
   173             nichost = self.choose_server(query_arg)
   175             print('nichost:', nichost)
       
   176             if nichost is not None:
   174             if nichost is not None:
   177                 result = self.whois(query_arg, nichost, flags)
   175                 result = self.whois(query_arg, nichost, flags)
   178             else:
   176             else:
   179                 result = ''
   177                 result = ''
   180         else:
   178         else: