]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
naoki: python 2.4 does not come with the email module.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Apr 2010 13:42:24 +0000 (15:42 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Apr 2010 13:42:24 +0000 (15:42 +0200)
So, we disable the email function here.

This affects CentOS 5.4.

naoki/backend.py

index 9129cc33306eb5e993e435fae2685b2cfe2d9678..1c7f69074e476d8de3493b287bbf7ed03226926f 100644 (file)
@@ -1,7 +1,6 @@
 #!/usr/bin/python
 
-import email.mime.multipart
-import email.mime.text
+
 import os
 import shutil
 import smtplib
@@ -20,6 +19,15 @@ __cache = {
        "group_names" : None,
 }
 
+# Python 2.4 does not have that email module, so
+# we disable the mail function here.
+try:
+       import email.mime.multipart
+       import email.mime.text
+       have_email = 1
+except ImportError:
+       have_email = 0
+
 try:
        import hashlib
        have_hashlib = 1
@@ -565,6 +573,10 @@ def report_error_by_mail(package):
        if not config["error_report_recipient"]:
                return
 
+       if not have_email:
+               log.error("Can't send mail because this python version does not support this")
+               return
+
        try:
                connection = smtplib.SMTP(config["smtp_server"])
                #connection.set_debuglevel(1)