From dfe3262212662970e5afd04a0bf5e4ebcc2eb88c Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sat, 11 Jan 2014 22:48:59 +0100 Subject: [PATCH] If PTR records are not UTF-8, ignore the conversion errors. --- bin/ptr-import.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/ptr-import.py b/bin/ptr-import.py index 3be0a17..6c44ab7 100644 --- a/bin/ptr-import.py +++ b/bin/ptr-import.py @@ -25,11 +25,11 @@ r = redis.StrictRedis(host='localhost', port=8323) if args.r: for x in args.r: - with open(x) as f: - for l in f: - (ip, ptr) = l.rstrip().split(',') - print (terms(ptr)) - r.set(ip,ptr) + with open(x, encoding='UTF-8', errors='ignore') as f: + for l in f: + (ip, ptr) = l.rstrip().split(',')[:2] + print (terms(ptr)) + r.set(ip,ptr) else: argParser.print_help() exit(1)