for part in msg.walk():
if part.get_content_type() == "text/plain":
- body = part.get_payload(decode=True).decode("utf-8")
- for key in content_types.keys():
- if key in body:
- return content_types[key]
- break
+ try:
+ body = part.get_payload(decode=True).decode("utf-8")
+ for key in content_types.keys():
+ if key in body:
+ return content_types[key]
+ break
+ except UnicodeDecodeError as e:
+ logging.warning("Failed to decode email: %s, treating as SPAM" % e)
+ break
return ContentType.SPAM
quiet_cmd(cmd)
# apply the patch
- cmd = ["b4", "shazam", "-m", "-"]
+ cmd = ["git", "am"]
logging.debug("Running {}".format(cmd))
p = subprocess.Popen(
cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE