mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-22 22:27:17 +00:00
Fix the exceptions
This commit is contained in:
parent
9e8611a42d
commit
b7c9e489c9
3 changed files with 100 additions and 98 deletions
|
@ -38,11 +38,9 @@ if __name__ == "__main__":
|
|||
is_critical = 10
|
||||
|
||||
email_regex = "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}"
|
||||
|
||||
MX_values = None
|
||||
while True:
|
||||
try:
|
||||
if message is not None:
|
||||
print message
|
||||
filename, word, score = message.split()
|
||||
|
||||
if prec_filename is None or filename != prec_filename:
|
||||
|
@ -72,6 +70,3 @@ if __name__ == "__main__":
|
|||
time.sleep(10)
|
||||
|
||||
message = p.get_from_set()
|
||||
except dns.exception.Timeout:
|
||||
# FIXME retry!
|
||||
print "dns.exception.Timeout"
|
||||
|
|
|
@ -45,7 +45,6 @@ if __name__ == "__main__":
|
|||
url_regex = "(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*"
|
||||
|
||||
while True:
|
||||
try:
|
||||
if message is not None:
|
||||
filename, word, score = message.split()
|
||||
|
||||
|
@ -111,5 +110,3 @@ if __name__ == "__main__":
|
|||
time.sleep(10)
|
||||
|
||||
message = p.get_from_set()
|
||||
except dns.exception.Timeout:
|
||||
print "dns.exception.Timeout", A_values
|
||||
|
|
|
@ -33,7 +33,9 @@ def checking_MX_record(r_serv, adress_set):
|
|||
WalidMX = set([])
|
||||
# Transforming the set into a string
|
||||
MXdomains = re.findall("@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,20}", str(adress_set).lower())
|
||||
|
||||
resolver = dns.resolver.Resolver()
|
||||
resolver.timeout = 5
|
||||
resolver.lifetime = 2
|
||||
if MXdomains != []:
|
||||
|
||||
for MXdomain in set(MXdomains):
|
||||
|
@ -45,9 +47,9 @@ def checking_MX_record(r_serv, adress_set):
|
|||
# Not already in Redis
|
||||
else:
|
||||
# If I'm Walid MX domain
|
||||
if dns.resolver.query(MXdomain[1:], rdtype=dns.rdatatype.MX):
|
||||
if resolver.query(MXdomain[1:], rdtype=dns.rdatatype.MX):
|
||||
# Gonna be added in redis.
|
||||
r_serv.setex(MXdomain[1:], timedelta(days=1), 1)
|
||||
r_serv.setex(MXdomain[1:], 1, timedelta(days=1))
|
||||
score += 1
|
||||
WalidMX.add(MXdomain[1:])
|
||||
else:
|
||||
|
@ -63,13 +65,17 @@ def checking_MX_record(r_serv, adress_set):
|
|||
publisher.debug('SyntaxError: EmptyLabel')
|
||||
|
||||
except dns.resolver.NXDOMAIN:
|
||||
r_serv.setex(MXdomain[1:], 1, timedelta(days=1))
|
||||
publisher.debug('The query name does not exist.')
|
||||
|
||||
except dns.name.LabelTooLong:
|
||||
publisher.debug('The Label is too long')
|
||||
|
||||
finally:
|
||||
pass
|
||||
except dns.resolver.Timeout:
|
||||
r_serv.setex(MXdomain[1:], 1, timedelta(days=1))
|
||||
|
||||
except Exception as e:
|
||||
print e
|
||||
|
||||
publisher.debug("emails before: {0} after: {1} (valid)".format(num, score))
|
||||
return (num, WalidMX)
|
||||
|
@ -79,6 +85,9 @@ def checking_A_record(r_serv, domains_set):
|
|||
score = 0
|
||||
num = len(domains_set)
|
||||
WalidA = set([])
|
||||
resolver = dns.resolver.Resolver()
|
||||
resolver.timeout = 5
|
||||
resolver.lifetime = 2
|
||||
|
||||
for Adomain in domains_set:
|
||||
try:
|
||||
|
@ -89,9 +98,9 @@ def checking_A_record(r_serv, domains_set):
|
|||
# Not already in Redis
|
||||
else:
|
||||
# If I'm Walid domain
|
||||
if dns.resolver.query(Adomain, rdtype=dns.rdatatype.A):
|
||||
if resolver.query(Adomain, rdtype=dns.rdatatype.A):
|
||||
# Gonna be added in redis.
|
||||
r_serv.setex(Adomain, timedelta(days=1), 1)
|
||||
r_serv.setex(Adomain, 1, timedelta(days=1))
|
||||
score += 1
|
||||
WalidA.add(Adomain)
|
||||
else:
|
||||
|
@ -107,13 +116,14 @@ def checking_A_record(r_serv, domains_set):
|
|||
publisher.debug('SyntaxError: EmptyLabel')
|
||||
|
||||
except dns.resolver.NXDOMAIN:
|
||||
r_serv.setex(Adomain[1:], 1, timedelta(days=1))
|
||||
publisher.debug('The query name does not exist.')
|
||||
|
||||
except dns.name.LabelTooLong:
|
||||
publisher.debug('The Label is too long')
|
||||
|
||||
finally:
|
||||
pass
|
||||
except Exception as e:
|
||||
print e
|
||||
|
||||
publisher.debug("URLs before: {0} after: {1} (valid)".format(num, score))
|
||||
return (num, WalidA)
|
||||
|
|
Loading…
Reference in a new issue