mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-12-14 10:52:49 +02:00
Update for usage with Python 3
- print with parantheses and .format - change import of email modules - change shebang
This commit is contained in:
parent
409ecf7fd5
commit
cf2e8d6545
@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import smtplib
|
import smtplib
|
||||||
import os
|
import os
|
||||||
from email.MIMEMultipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.MIMEText import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.Utils import COMMASPACE, formatdate
|
from email.utils import COMMASPACE, formatdate
|
||||||
import jinja2
|
import jinja2
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
import redis
|
import redis
|
||||||
@ -17,7 +17,7 @@ if len(sys.argv) > 2:
|
|||||||
percent = int(sys.argv[1])
|
percent = int(sys.argv[1])
|
||||||
username = str(sys.argv[2])
|
username = str(sys.argv[2])
|
||||||
else:
|
else:
|
||||||
print "Args missing"
|
print("Args missing")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@ -25,7 +25,7 @@ while True:
|
|||||||
r = redis.StrictRedis(host='redis', decode_responses=True, port=6379, db=0)
|
r = redis.StrictRedis(host='redis', decode_responses=True, port=6379, db=0)
|
||||||
r.ping()
|
r.ping()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print '%s - trying again...' % (ex)
|
print("{0} - trying again...".format(ex))
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
@ -34,7 +34,7 @@ if r.get('QW_HTML'):
|
|||||||
try:
|
try:
|
||||||
template = Template(r.get('QW_HTML'))
|
template = Template(r.get('QW_HTML'))
|
||||||
except:
|
except:
|
||||||
print "Error: Cannot parse quarantine template, falling back to default template."
|
print("Error: Cannot parse quarantine template, falling back to default template.")
|
||||||
with open('/templates/quota.tpl') as file_:
|
with open('/templates/quota.tpl') as file_:
|
||||||
template = Template(file_.read())
|
template = Template(file_.read())
|
||||||
else:
|
else:
|
||||||
@ -58,7 +58,7 @@ try:
|
|||||||
p.communicate(input=msg.as_string())
|
p.communicate(input=msg.as_string())
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print 'Failed to send quota notification: %s' % (ex)
|
print('Failed to send quota notification: {0}'.format(ex))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user