def mirrors(self):
"""
Return the list of hostnames which are mirrors for this index.
:return: A (possibly empty) list of hostnames of mirrors.
"""
result = []
try:
host = socket.gethostbyname_ex(self.mirror_host)[0]
except socket.gaierror: # pragma: no cover
host = None
if host:
last, rest = host.split('.', 1)
n = len(last)
host_list = (''.join(w) for w in itertools.chain.from_iterable(
itertools.product(ascii_lowercase, repeat=i)
for i in range(1, n + 1)))
for s in host_list:
result.append('.'.join((s, rest)))
if s == last:
break
return result
评论列表
文章目录