handle the ValueError in SpamAssassin
This commit is contained in:
parent
6253a4eb23
commit
cbdcab7d24
|
@ -4,6 +4,8 @@ https://github.com/petermat/spamassassin_client
|
||||||
import socket, select, re, logging
|
import socket, select, re, logging
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
from app.log import LOG
|
||||||
|
|
||||||
divider_pattern = re.compile(br"^(.*?)\r?\n(.*?)\r?\n\r?\n", re.DOTALL)
|
divider_pattern = re.compile(br"^(.*?)\r?\n(.*?)\r?\n\r?\n", re.DOTALL)
|
||||||
first_line_pattern = re.compile(br"^SPAMD/[^ ]+ 0 EX_OK$")
|
first_line_pattern = re.compile(br"^SPAMD/[^ ]+ 0 EX_OK$")
|
||||||
|
|
||||||
|
@ -101,10 +103,13 @@ class SpamAssassin(object):
|
||||||
self.report_json = dict()
|
self.report_json = dict()
|
||||||
for tablelist in tablelists:
|
for tablelist in tablelists:
|
||||||
wordlist = re.split("\s+", tablelist)
|
wordlist = re.split("\s+", tablelist)
|
||||||
|
try:
|
||||||
self.report_json[wordlist[1]] = {
|
self.report_json[wordlist[1]] = {
|
||||||
"partscore": float(wordlist[0]),
|
"partscore": float(wordlist[0]),
|
||||||
"description": " ".join(wordlist[1:]),
|
"description": " ".join(wordlist[1:]),
|
||||||
}
|
}
|
||||||
|
except ValueError:
|
||||||
|
LOG.warning("Cannot parse %s %s", wordlist[0], wordlist)
|
||||||
|
|
||||||
headers = (
|
headers = (
|
||||||
headers.decode("utf-8")
|
headers.decode("utf-8")
|
||||||
|
|
Loading…
Reference in a new issue