rpms/epylog/devel epylog-1.0.3-mimewriter.patch, NONE, 1.1 epylog.spec, 1.14, 1.15

Konstantin Ryabitsev icon at fedoraproject.org
Fri Jul 16 18:41:29 UTC 2010


Author: icon

Update of /cvs/pkgs/rpms/epylog/devel
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv5554/devel

Modified Files:
	epylog.spec 
Added Files:
	epylog-1.0.3-mimewriter.patch 
Log Message:
Attach patch to fix mimewriter deprecation warning.


epylog-1.0.3-mimewriter.patch:
 publishers.py |  261 +++++++++++-----------------------------------------------
 1 file changed, 53 insertions(+), 208 deletions(-)

--- NEW FILE epylog-1.0.3-mimewriter.patch ---
diff -ur epylog-1.0.3/py/epylog/publishers.py epylog-1.0.3.patched/py/epylog/publishers.py
--- epylog-1.0.3/py/epylog/publishers.py	2004-02-09 15:31:42.000000000 -0500
+++ epylog-1.0.3.patched/py/epylog/publishers.py	2010-07-16 14:30:57.267789296 -0400
@@ -260,48 +260,52 @@
                 self.gzlogs = outfh.read()
             outfh.close()
             
-        ##
-        # Using MimeWriter, since package 'email' doesn't come with rhl-7.3
-        # Suck-o.
-        #
         logger.puthang(3, 'Creating an email message')
-        import StringIO, MimeWriter
-        fh = StringIO.StringIO()
+        from email.mime.base      import MIMEBase
+        from email.mime.text      import MIMEText
+        from email.mime.multipart import MIMEMultipart
+
         logger.put(5, 'Creating a main header')
-        mw = MimeWriter.MimeWriter(fh)
-        mw.addheader('Subject', title)
-        if len(self.mailto) > 1:
-            import string
-            tostr = string.join(self.mailto, ', ')
-        else:
-            tostr = self.mailto[0]
-        mw.addheader('To', tostr)
-        mw.addheader('X-Mailer', epylog.VERSION)
-        self.mw = mw
+        root_part = MIMEMultipart('related')
+        root_part['Subject'] = title
+        root_part['To'] = ', '.join(self.mailto)
+        root_part['X-Mailer'] = epylog.VERSION
+        root_part.preamble = 'This is a multi-part message in MIME format.'
+
+        logger.put(5, 'Creating the text/plain part')
+        text_part = MIMEText(self.plainrep, 'plain', 'utf-8')
+        logger.put(5, 'Creating the text/html part')
+        html_part = MIMEText(self.htmlrep, 'html', 'utf-8')
+        
+        if self.rawlogs > 0:
+            logger.put(5, 'Creating the application/x-gzip part')
+            attach_part = MIMEBase('application', 'x-gzip')
+            attach_part.set_payload(self.gzlogs)
+            from email.encoders import encode_base64
+            logger.put(5, 'Encoding the gzipped raw logs with base64')
+            encode_base64(attach_part)
+            attach_part.add_header('Content-Disposition', 'attachment', 
+                                   filename='raw.log.gz')
         
-        if self.rawlogs > 0 and self.format == 'both':
-            logger.put(5, 'Making a html + plain + gzip message')
-            self._mk_both_rawlogs()
-        elif self.rawlogs > 0 and self.format == 'html':
-            logger.put(5, 'Making a html + gzip message')
-            self._mk_html_rawlogs()
-        elif self.rawlogs > 0 and self.format == 'plain':
-            logger.put(5, 'Making a plain + gzip message')
-            self._mk_plain_rawlogs()
-        elif self.rawlogs == 0 and self.format == 'both':
-            logger.put(5, 'Making a html + plain message')
-            self._mk_both_nologs()
-        elif self.rawlogs == 0 and self.format == 'html':
-            logger.put(5, 'Making a html message')
-            self._mk_html_nologs()
-        elif self.rawlogs == 0 and self.format == 'plain':
-            logger.put(5, 'Making a plain message')
-            self._mk_plain_nologs()
+        if self.format == 'both':
+            # create another multipart for text+html
+            alt_part = MIMEMultipart('alternative')
+            alt_part.attach(text_part)
+            alt_part.attach(html_part)
+            root_part.attach(alt_part)
+        elif self.format == 'html':
+            root_part.attach(html_part)
+        elif self.format == 'plain':
+            root_part.attach(text_part)
+
+        if self.rawlogs > 0:
+            root_part.attach(attach_part)
+
         logger.endhang(3)
+        
+        logger.put(5, 'Creating the message as string')
+        msg = root_part.as_string()
 
-        fh.seek(0)
-        msg = fh.read()
-        fh.close()
         logger.put(5, 'Message follows')
         logger.put(5, msg)
         logger.put(5, 'End of message')
@@ -312,163 +316,9 @@
         else:
             fromaddr = 'root@%s' % socket.gethostname()
             mail_smtp(self.smtpserv, fromaddr, self.mailto, msg, logger)
-        logger.put(1, 'Mailed the report to: %s' % tostr)
+        logger.put(1, 'Mailed the report to: %s' % ','.join(self.mailto))
         logger.put(5, '<MailPublisher.publish')
 
-    def _mk_both_rawlogs(self):
-        """
-        Make an email message that includes html, plaintext, and gzipped raw
-        logs sections. Most painful.
-        """
-        self.logger.put(5, '>MailPublisher._mk_both_rawlogs')
-        import base64
-        logger = self.logger
-        mixed_mw = self.mw
-        mixed_mw.addheader('Mime-Version', '1.0')
-        logger.put(5, 'Creating a multipart/mixed part')
-        mixed_mw.startmultipartbody('mixed')
-
-        logger.put(5, 'Creating a multipart/alternative part')
-        alt_mw = mixed_mw.nextpart()
-        alt_mw.startmultipartbody('alternative')
-
-        logger.put(5, 'Creating a text/plain part')
-        plain_mw = alt_mw.nextpart()
-        plain_mw.addheader('Content-Transfer-Encoding', '8bit')
-        plain_fh = plain_mw.startbody('text/plain; charset=iso-8859-1')
-        plain_fh.write(self.plainrep)
-
-        logger.put(5, 'Creating a text/html part')
-        html_mw = alt_mw.nextpart()
-        html_mw.addheader('Content-Transfer-Encoding', '8bit')
-        html_fh = html_mw.startbody('text/html; charset=iso-8859-1')
-        html_fh.write(self.htmlrep)
-
-        alt_mw.lastpart()
-        logger.put(5, 'Creating an application/gzip part')
-        gzip_mw = mixed_mw.nextpart()
-        gzip_mw.addheader('Content-Transfer-Encoding', 'base64')
-        gzip_mw.addheader('Content-Disposition',
-                          'attachment; filename=rawlogs.gz')
-        gzip_fh = gzip_mw.startbody('application/gzip; NAME=rawlogs.gz')
-        gzip_fh.write(base64.encodestring(self.gzlogs))
-        mixed_mw.lastpart()
-        self.logger.put(5, '<MailPublisher._mk_both_rawlogs')
-
-    def _mk_html_rawlogs(self):
-        """
-        Make an email message that includes html and gzipped raw logs sections.
-        """
-        self.logger.put(5, '>MailPublisher._mk_html_rawlogs')
-        import base64
-        logger = self.logger
-        mixed_mw = self.mw
-        mixed_mw.addheader('Mime-Version', '1.0')
-        logger.put(5, 'Creating a multipart/mixed part')
-        mixed_mw.startmultipartbody('mixed')
-
-        logger.put(5, 'Creating a text/html part')
-        html_mw = mixed_mw.nextpart()
-        html_mw.addheader('Content-Transfer-Encoding', '8bit')
-        html_fh = html_mw.startbody('text/html; charset=iso-8859-1')
-        html_fh.write(self.htmlrep)
-
-        logger.put(5, 'Creating an application/gzip part')
-        gzip_mw = mixed_mw.nextpart()
-        gzip_mw.addheader('Content-Transfer-Encoding', 'base64')
-        gzip_mw.addheader('Content-Disposition',
-                          'attachment; filename=rawlogs.gz')
-        gzip_fh = gzip_mw.startbody('application/gzip; NAME=rawlogs.gz')
-        gzip_fh.write(base64.encodestring(self.gzlogs))
-        mixed_mw.lastpart()
-        self.logger.put(5, '<MailPublisher._mk_html_rawlogs')
-
-    def _mk_plain_rawlogs(self):
-        """
-        Make an email message that includes plaintext and gzipped raw logs
-        sections.
-        """
-        self.logger.put(5, '>MailPublisher._mk_plain_rawlogs')
-        import base64
-        logger = self.logger
-        mixed_mw = self.mw
-        mixed_mw.addheader('Mime-Version', '1.0')
-        logger.put(5, 'Creating a multipart/mixed part')
-        mixed_mw.startmultipartbody('mixed')
-
-        logger.put(5, 'Creating a text/plain part')
-        plain_mw = mixed_mw.nextpart()
-        plain_mw.addheader('Content-Transfer-Encoding', '8bit')
-        plain_fh = plain_mw.startbody('text/plain; charset=iso-8859-1')
-        plain_fh.write(self.plainrep)
-
-        logger.put(5, 'Creating an application/gzip part')
-        gzip_mw = mixed_mw.nextpart()
-        gzip_mw.addheader('Content-Transfer-Encoding', 'base64')
-        gzip_mw.addheader('Content-Disposition',
-                          'attachment; filename=rawlogs.gz')
-        gzip_fh = gzip_mw.startbody('application/gzip; NAME=rawlogs.gz')
-        gzip_fh.write(base64.encodestring(self.gzlogs))
-        mixed_mw.lastpart()
-        self.logger.put(5, '<MailPublisher._mk_plain_rawlogs')
-
-    def _mk_both_nologs(self):
-        """
-        Make a message that just includes html and plaintext sections.
-        """
-        self.logger.put(5, '>MailPublisher._mk_both_nologs')
-        logger = self.logger
-        alt_mw = self.mw
-        alt_mw.addheader('Mime-Version', '1.0')
-        logger.put(5, 'Creating a multipart/alternative part')
-        alt_mw.startmultipartbody('alternative')
-
-        logger.put(5, 'Creating a text/plain part')
-        plain_mw = alt_mw.nextpart()
-        plain_mw.addheader('Content-Transfer-Encoding', '8bit')
-        plain_fh = plain_mw.startbody('text/plain; charset=iso-8859-1')
-        plain_fh.write(self.plainrep)
-
-        logger.put(5, 'Creating a text/html part')
-        html_mw = alt_mw.nextpart()
-        html_mw.addheader('Content-Transfer-Encoding', '8bit')
-        html_fh = html_mw.startbody('text/html; charset=iso-8859-1')
-        html_fh.write(self.htmlrep)
-
-        alt_mw.lastpart()
-        self.logger.put(5, '<MailPublisher._mk_both_nologs')
-
-    def _mk_html_nologs(self):
-        """
-        Make a message that just includes HTML-formatted section.
-        """
-        self.logger.put(5, '>MailPublisher._mk_html_nologs')
-        logger = self.logger
-        alt_mw = self.mw
-        alt_mw.addheader('Mime-Version', '1.0')
-        logger.put(5, 'Creating a multipart/alternative part')
-        alt_mw.startmultipartbody('alternative')
-        logger.put(5, 'Creating a text/html part')
-        html_mw = alt_mw.nextpart()
-        html_mw.addheader('Content-Transfer-Encoding', '8bit')
-        html_fh = html_mw.startbody('text/html; charset=iso-8859-1')
-        html_fh.write(self.htmlrep)
-        alt_mw.lastpart()
-        self.logger.put(5, '<MailPublisher._mk_html_nologs')
-
-    def _mk_plain_nologs(self):
-        """
-        Make a message that just includes a plaintext-formatted section.
-        """
-        self.logger.put(5, '>MailPublisher._mk_plain_nologs')
-        logger = self.logger
-        plain_mw = self.mw
-        logger.put(5, 'Creating a text/plain part')
-        plain_mw.addheader('Content-Transfer-Encoding', '8bit')
-        plain_fh = plain_mw.startbody('text/plain; charset=iso-8859-1')
-        plain_fh.write(self.plainrep)
-        self.logger.put(5, '<MailPublisher._mk_plain_nologs')
-
 
 class FilePublisher:
     """
@@ -586,28 +436,23 @@
         if self.notify:
             logger.puthang(3, 'Creating an email message')
             publoc = '%s/%s/%s' % (self.pubroot, self.dirname, filename)
-            msg = 'New Epylog report is available at:\r\n%s' % publoc
-            import StringIO, MimeWriter
-            fh = StringIO.StringIO()
-            logger.put(3, 'Creating a main header')
-            mw = MimeWriter.MimeWriter(fh)
-            mw.addheader('Subject', '%s (report notification)' % title)
-            tostr = ', '.join(self.notify)
-            mw.addheader('To', tostr)
-            mw.addheader('X-Mailer', epylog.VERSION)
-            mw.addheader('Content-Transfer-Encoding', '8bit')
-            bfh = mw.startbody('text/plain; charset=iso-8859-1')
-            bfh.write(msg)
-            fh.seek(0)
-            msg = fh.read()
-            fh.close()
+
+            from email.mime.text import MIMEText
+            eml = MIMEText('New Epylog report is available at:\r\n%s' % publoc)
+
+            eml['Subject'] = '%s (report notification)' % title
+            eml['To'] = ', '.join(self.notify)
+            eml['X-Mailer'] = epylog.VERSION
+
+            msg = eml.as_string()
+
             logger.put(3, 'Figuring out if we are using sendmail or smtplib')
             if re.compile('^/').search(self.smtpserv):
                 mail_sendmail(self.smtpserv, msg, logger)
             else:
                 fromaddr = 'root@%s' % socket.gethostname()
                 mail_smtp(self.smtpserv, fromaddr, self.notify, msg, logger)
-            logger.put(1, 'Notification mailed to: %s' % tostr)
+            logger.put(1, 'Notification mailed to: %s' % ','.join(self.notify))
 
         logfilen = '%s.log' % self.filename
         logfile = os.path.join(self.path, '%s.gz' % logfilen)


Index: epylog.spec
===================================================================
RCS file: /cvs/pkgs/rpms/epylog/devel/epylog.spec,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -p -r1.14 -r1.15
--- epylog.spec	1 Jun 2010 14:45:27 -0000	1.14
+++ epylog.spec	16 Jul 2010 18:41:29 -0000	1.15
@@ -2,13 +2,14 @@
 
 Name:           epylog
 Version:        1.0.3
-Release:        12%{?dist}
+Release:        13%{?dist}
 Summary:        New logs analyzer and parser
 
 Group:          Applications/System
 License:        GPLv2+
-URL:            http://linux.duke.edu/projects/epylog/
-Source:         http://linux.duke.edu/projects/epylog/download/epylog-%{version}.tar.gz
+URL:            https://fedorahosted.org/epylog/
+Source:         http://fedorapeople.org/~icon/epylog/epylog-%{version}.tar.gz
+Patch0:         epylog-1.0.3-mimewriter.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch:      noarch
 
@@ -42,6 +43,10 @@ external perl modules, or intend to writ
 %prep
 %setup -q
 ##
+# Apply mimewriter patch
+#
+%patch0 -p1
+##
 # The --with-lynx is just a sane default. Epylog doesn't actually require 
 # it to run in the out-of-the-box configuration.
 #
@@ -97,6 +102,10 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Fri Jul 16 2010 Konstantin Ryabitsev <icon at fedoraproject.org> - 1.0.3-13
+- Patch to fix MimeWriter warning
+- Adjust URLs
+
 * Tue Jun 01 2010 Marcela Maslanova <mmaslano at redhat.com> - 1.0.3-12
 - Mass rebuild with perl-5.12.0
 



More information about the scm-commits mailing list