utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:flowder 作者: amir-khakshour 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号