[Libreoffice-commits] dev-tools.git: 2 commits - gerritbot/send-daily-digest

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Thu Jun 6 12:28:41 PDT 2013


 gerritbot/send-daily-digest |   41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

New commits:
commit 229be4ab7d8b18515ec507bac7fa3f76cee03b0d
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Jun 6 21:27:54 2013 +0200

    proper time

diff --git a/gerritbot/send-daily-digest b/gerritbot/send-daily-digest
index eede87b..e1e9c3f 100755
--- a/gerritbot/send-daily-digest
+++ b/gerritbot/send-daily-digest
@@ -10,6 +10,8 @@
 
 import argparse
 import datetime
+import time
+import email
 import email.mime.text
 import json
 import os
@@ -52,7 +54,7 @@ Note: The bot generating this message can be found and improved here:
     msg = email.mime.text.MIMEText(body, 'plain', 'UTF-8')
     msg['From'] = 'gerrit at libreoffice.org'
     msg['To'] = 'libreoffice at lists.freedesktop.org'
-    msg['Date'] = str(now)
+    msg['Date'] = email.utils.formatdate(time.mktime((now.timetuple())))
     msg['Subject'] = 'LibreOffice Gerrit News %s' % now.date().isoformat()
     msg['Reply-To'] = 'ibreoffice at lists.freedesktop.org'
     msg['X-Mailer'] = 'LibreOfficeGerritDigestMailer 1.0'
commit 05060611ed5df411887c153880752159e7618143
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Jun 6 21:24:28 2013 +0200

    proper MIME and UTF-8

diff --git a/gerritbot/send-daily-digest b/gerritbot/send-daily-digest
index f8273c2..eede87b 100755
--- a/gerritbot/send-daily-digest
+++ b/gerritbot/send-daily-digest
@@ -9,9 +9,8 @@
 #
 
 import argparse
-import codecs
 import datetime
-import email
+import email.mime.text
 import json
 import os
 import sh
@@ -33,24 +32,16 @@ def get_digest(gerrit, query):
     
 def create_message(gerrit, age):
     now = datetime.datetime.now()
-    message = '''From: gerrit at libreoffice.org
-To: libreoffice at lists.freedesktop.org
-Date: %s
-Subject: LibreOffice Gerrit news %s
-Reply-To: libreoffice at lists.freedesktop.org
-X-Mailer: LibreOfficeGerritDigestMailer 1.0
-
-''' % (now, now.date().isoformat())
-    message += 'Moin!\n\n'
-    message += 'open changes on master for project core changed in the last %d hours:\n' % age
-    message += get_digest(gerrit, get_daily_query('open', age))
-    message += '\n\nmerged changes on master for project core changed in the last %d hours:\n' % age
-    message += get_digest(gerrit, get_daily_query('merged', age))
-    message += '\n\nabandoned changes on master for project core changed in the last %d hours:\n' % age
-    message += get_digest(gerrit, get_daily_query('abandoned', age))
-    message += '\n\nOpen changes needing tweaks, but being untouched for more than a week:\n'
-    message += get_digest(gerrit, 'project:core branch:master status:open (label:Code-Review<=-1 label:Verified<=-1) age:1w')
-    message += '''
+    body = 'Moin!\n\n'
+    body += 'open changes on master for project core changed in the last %d hours:\n' % age
+    body += get_digest(gerrit, get_daily_query('open', age))
+    body += '\n\nmerged changes on master for project core changed in the last %d hours:\n' % age
+    body += get_digest(gerrit, get_daily_query('merged', age))
+    body += '\n\nabandoned changes on master for project core changed in the last %d hours:\n' % age
+    body += get_digest(gerrit, get_daily_query('abandoned', age))
+    body += '\n\nOpen changes needing tweaks, but being untouched for more than a week:\n'
+    body += get_digest(gerrit, 'project:core branch:master status:open (label:Code-Review<=-1 label:Verified<=-1) age:1w')
+    body += '''
 
 Best,
 
@@ -58,7 +49,14 @@ Your friendly LibreOffice Gerrit Digest Mailer
 
 Note: The bot generating this message can be found and improved here:
        https://gerrit.libreoffice.org/gitweb?p=dev-tools.git;a=blob;f=gerritbot/send-daily-digest'''
-    return message
+    msg = email.mime.text.MIMEText(body, 'plain', 'UTF-8')
+    msg['From'] = 'gerrit at libreoffice.org'
+    msg['To'] = 'libreoffice at lists.freedesktop.org'
+    msg['Date'] = str(now)
+    msg['Subject'] = 'LibreOffice Gerrit News %s' % now.date().isoformat()
+    msg['Reply-To'] = 'ibreoffice at lists.freedesktop.org'
+    msg['X-Mailer'] = 'LibreOfficeGerritDigestMailer 1.0'
+    return msg
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser('gerrit daily digest generator')
@@ -67,6 +65,5 @@ if __name__ == '__main__':
 	#server = smtplib.SMTP('localhost')
     #server.sendmail('gerrit at libreoffice.org', 'libreoffice at lists.freedesktop.org', str(message))
 	#server.quit()
-    sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
     print(create_message(args['gerrit'], 25))
 # vim: set et sw=4 ts=4:


More information about the Libreoffice-commits mailing list