Skip to content

Commit a1c48c3

Browse files
committed
Update for python3
1 parent e518f3b commit a1c48c3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

mail-blocks.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ def find_blocked_mail(blocked_mail, earliest_timestamp, f):
7878
#line_match = re.search('(?P<date>[A-Z][a-z][a-z]\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}).*amavis\[\d+\].*Blocked (?P<reason>\w+).* <(?P<from>[^<>]+)> -> (?P<to><[^<>]+>)+, quarantine: (?P<filename>[^,]+), Message-ID:', line)
7979
line_match = re.match(r'(?P<date>[A-Z][a-z][a-z]\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}).*amavis\[\d+\].*Blocked (?P<reason>\w+).* <(?P<from>[^<>]+)> -> (?P<to>(<[^<>]+>,?)+), quarantine: (?P<filename>[^,]+),', line)
8080
if not line_match == None:
81-
#print "Matched"
82-
#print "to: " + line_match.group("to")
83-
#print line
84-
#print "date:", line_match.group("date"), "reason:", line_match.group("reason"), "from:", line_match.group("from"), "to:", line_match.group("to"), "filename:", line_match.group("filename")
81+
#print("Matched")
82+
#print("to: " + line_match.group("to"))
83+
#print(line)
84+
#print("date:", line_match.group("date"), "reason:", line_match.group("reason"), "from:", line_match.group("from"), "to:", line_match.group("to"), "filename:", line_match.group("filename"))
8585
dropped_message = DroppedMessage()
8686
dropped_message.email_from = line_match.group("from")
8787
dropped_message.filename = line_match.group("filename")
@@ -102,9 +102,9 @@ def find_blocked_mail(blocked_mail, earliest_timestamp, f):
102102
continue
103103
user = match.group("user")
104104
#user = email.split('@')[0]
105-
#print "user #" + user + "#"
105+
#print("user #" + user + "#")
106106
if not re.match("[A-Z0-9._%-]+", user, re.IGNORECASE):
107-
#print "Invalid user found in to list", user, ", skipping"
107+
#print("Invalid user found in to list", user, ", skipping")
108108
continue
109109

110110
if not blocked_mail.has_key(user):
@@ -128,7 +128,7 @@ def find_blocked_mail(blocked_mail, earliest_timestamp, f):
128128
(options, args) = parser.parse_args()
129129

130130
if options.logfile_pattern == None:
131-
print "A logfile pattern must be specified"
131+
print("A logfile pattern must be specified")
132132
parser.print_help()
133133
sys.exit()
134134

@@ -194,19 +194,19 @@ def find_blocked_mail(blocked_mail, earliest_timestamp, f):
194194
msg['To'] = blocked_mail.email
195195

196196
if options.debug:
197-
print msg
197+
print(msg)
198198
else:
199199
try:
200200
smtp.sendmail(options.contact, [blocked_mail.email], msg.as_string())
201201
except:
202-
print "Error sending message to %s, will continue with next recipient" % (blocked_mail.email)
202+
print("Error sending message to %s, will continue with next recipient" % (blocked_mail.email))
203203

204204
#summary msg = MIMEText(summary_mail_body)
205205
#summary msg['Subject'] = 'Summary Digest of blocked email on mtu.net'
206206
#summary msg['From'] = options.contact
207207
#summary msg['To'] = options.contact
208208
#summary if options.debug:
209-
#summary print msg
209+
#summary print(msg)
210210
#summary else:
211211
#summary smtp.sendmail(options.contact, [options.contact], msg.as_string())
212212

0 commit comments

Comments
 (0)