def parse_clients_list(file_path):
trusted_clients = None
# @TODO create a service to read trusted clients from DB
try:
trusted_clients = open(file_path, 'r').readlines()
trusted_clients = map(lambda c: c.replace('\n', ''), trusted_clients)
except IOError:
_clients = []
log.warn("Trusted clinets list not found.")
clients_list = {}
if trusted_clients:
for row in csv.reader(trusted_clients, dialect='pipes', quotechar='!'):
_host, _user, _pass = row
if ip_re.match(_host):
_ip = _host
else:
_host = prepare_url(_host)
parsed_url = urlparse(_host)
_ip = yield client.getHostByName(parsed_url.netloc)
clients_list[_ip] = {'host': _host, 'user': _user, 'pass': _pass}
defer.returnValue(clients_list)
评论列表
文章目录