[Libreoffice-commits] dev-tools.git: 5 commits - gerritbot/gerrit_daily_digest gerritbot/send-daily-digest scripts/gerrit_daily_digest.py
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Thu Jun 6 10:28:30 PDT 2013
gerritbot/gerrit_daily_digest | 39 +++++++++++++++++++++++
gerritbot/send-daily-digest | 69 +++++++++++++++++++++++++++++++++++++++++
scripts/gerrit_daily_digest.py | 64 --------------------------------------
3 files changed, 108 insertions(+), 64 deletions(-)
New commits:
commit 792546d5773879580fb4f30d3e76c20387c3dc74
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jun 6 19:26:44 2013 +0200
initial version -- still doesnt send
diff --git a/gerritbot/send-daily-digest b/gerritbot/send-daily-digest
new file mode 100755
index 0000000..90274bc
--- /dev/null
+++ b/gerritbot/send-daily-digest
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import argparse
+import codecs
+import datetime
+import email
+import json
+import os
+import sh
+import smtplib
+import sys
+
+def get_daily_query(status, age):
+ return 'project:core branch:master status:%s -age:%dh' % (status, age)
+
+def get_digest(gerrit, query):
+ digest = ''
+ for line in sh.ssh(gerrit, 'gerrit query --format=JSON \'%s\'' % query).strip().split('\n'):
+ change = json.loads(line)
+ if 'url' in change.keys():
+ digest += '%s %s %s\n' % (change['url'], change['subject'].ljust(75)[:75], change['owner']['email'])
+ if digest == '':
+ digest = 'None'
+ return digest
+
+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 += '''
+
+Best,
+
+Your friendly LibreOffice Gerrit Digest Mailer'''
+ return message
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser('gerrit daily digest generator')
+ parser.add_argument('-g', '--gerrit', help='(i. e. logerrit or gerrit.libreoffice.org, use alias in your ~/.ssh(config with your public key)', required=True)
+ args=vars(parser.parse_args())
+ #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:
commit 1d38493ce916c39c9289b8ba32bead3f026c9907
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jun 6 15:36:52 2013 +0200
no ugly file extension needed
diff --git a/gerritbot/gerrit_daily_digest b/gerritbot/gerrit_daily_digest
new file mode 100755
index 0000000..02ca161
--- /dev/null
+++ b/gerritbot/gerrit_daily_digest
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+'''
+Created on 19.06.2012
+
+ at author: david ostrovsky
+'''
+
+from json import loads
+import argparse
+import sh
+
+def main():
+ parser = argparse.ArgumentParser('gerrit daily digest generator')
+ parser.add_argument('-s', '--status', choices=['open', 'merged', 'abandoned'], required=True)
+ parser.add_argument('-g', '--gerrit', help='(i. e. logerrit or gerrit.libreoffice.org, use alias in your ~/.ssh(config with your public key)', required=True)
+ parser.add_argument('-p', '--project', help='(i. e. core)', required=True)
+ parser.add_argument('-b', '--branch', help='(i. e. master)', required=True)
+ args=vars(parser.parse_args())
+ gerrit_host_name = args['gerrit']
+ status = args['status']
+ project = args['project']
+ branch = args['branch']
+ lines = sh.ssh(gerrit_host_name, 'gerrit', 'query', '--format=JSON', 'status:%s' % status, 'project:%s' % project, 'branch:%s' % branch)
+ for chunk in lines.strip().split("\n"):
+ data = loads(chunk)
+ if 'url' in data.keys():
+ print data['url'] + " \"" + data['subject'] + "\" " + data['owner']['email']
+
+if __name__ == "__main__":
+ main()
+# vim: set et sw=4 ts=4:
diff --git a/gerritbot/gerrit_daily_digest.py b/gerritbot/gerrit_daily_digest.py
deleted file mode 100755
index 02ca161..0000000
--- a/gerritbot/gerrit_daily_digest.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-'''
-Created on 19.06.2012
-
- at author: david ostrovsky
-'''
-
-from json import loads
-import argparse
-import sh
-
-def main():
- parser = argparse.ArgumentParser('gerrit daily digest generator')
- parser.add_argument('-s', '--status', choices=['open', 'merged', 'abandoned'], required=True)
- parser.add_argument('-g', '--gerrit', help='(i. e. logerrit or gerrit.libreoffice.org, use alias in your ~/.ssh(config with your public key)', required=True)
- parser.add_argument('-p', '--project', help='(i. e. core)', required=True)
- parser.add_argument('-b', '--branch', help='(i. e. master)', required=True)
- args=vars(parser.parse_args())
- gerrit_host_name = args['gerrit']
- status = args['status']
- project = args['project']
- branch = args['branch']
- lines = sh.ssh(gerrit_host_name, 'gerrit', 'query', '--format=JSON', 'status:%s' % status, 'project:%s' % project, 'branch:%s' % branch)
- for chunk in lines.strip().split("\n"):
- data = loads(chunk)
- if 'url' in data.keys():
- print data['url'] + " \"" + data['subject'] + "\" " + data['owner']['email']
-
-if __name__ == "__main__":
- main()
-# vim: set et sw=4 ts=4:
diff --git a/scripts/gerrit_daily_digest.py b/scripts/gerrit_daily_digest.py
deleted file mode 100755
index 510c60f..0000000
--- a/scripts/gerrit_daily_digest.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python
-
-'''
-Created on 19.06.2012
-
- at author: david ostrovsky
-'''
-
-from subprocess import check_output, STDOUT
-from json import loads
-import getopt, sys
-#from pprint import pprint
-
-def main():
- try:
- opts, args = getopt.getopt(sys.argv[1:], "hs:g:b:p:", ["help", "status=", "gerrit=", "branch=", "project="])
- except getopt.GetoptError, err:
- # print help information and exit:
- print str(err) # will print something like "option -a not recognized"
- usage()
- sys.exit(2)
- gerrit_host_name = None
- status = None
- project = None
- branch = None
- for o, a in opts:
- if o in ("-h", "--help"):
- usage()
- sys.exit()
- elif o in ("-s", "--status"):
- status = a
- elif o in ("-g", "--gerrit"):
- gerrit_host_name = a
- elif o in ("-p", "--project"):
- project = a
- elif o in ("-b", "--branch"):
- branch = a
- else:
- assert False, "unhandled option"
- if branch == None or gerrit_host_name == None or status == None or project == None or branch == None:
- usage()
- sys.exit(2)
-
- cmd = "ssh " + gerrit_host_name + " gerrit query --format=JSON status:" + status + " project:core branch:master"
- lines = check_output(cmd, shell=True, stderr=STDOUT).strip()
- for chunk in lines.split("\n"):
- data = loads(chunk)
- #pprint(data)
- if 'url' in data.keys():
- print data['url'] + " \"" + data['subject'] + "\" " + data['owner']['email']
-
-def usage():
- print """gerrit_daily_digest.py
- -g --gerrit (i. e. logerrit or gerrit.libreoffice.org, use alias in your ~/.ssh(config with your public key)
- -s --status (open, merged, abandoned)
- -p --project (i. e. core)
- -b --branch (i. e. master)
- -v --verbose
- -h --help
- Example: gerrit_daily_digest.py -g logerrit -s merged -p core -b master
- """
-
-if __name__ == "__main__":
- main()
commit 66b165fea4bb1c42f2f60e966a3466ecef5ae7f6
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jun 6 15:36:05 2013 +0200
use sh from amoffat.github.io/sh/ instead
diff --git a/gerritbot/gerrit_daily_digest.py b/gerritbot/gerrit_daily_digest.py
index 59ac20e..02ca161 100755
--- a/gerritbot/gerrit_daily_digest.py
+++ b/gerritbot/gerrit_daily_digest.py
@@ -13,11 +13,9 @@ Created on 19.06.2012
@author: david ostrovsky
'''
-from subprocess import check_output, STDOUT
from json import loads
-import getopt, sys
import argparse
-#from pprint import pprint
+import sh
def main():
parser = argparse.ArgumentParser('gerrit daily digest generator')
@@ -30,11 +28,9 @@ def main():
status = args['status']
project = args['project']
branch = args['branch']
- cmd = 'ssh %s gerrit query --format=JSON status:%s project:%s branch:%s' % (gerrit_host_name, status, project, branch)
- lines = check_output(cmd, shell=True, stderr=STDOUT).strip()
- for chunk in lines.split("\n"):
+ lines = sh.ssh(gerrit_host_name, 'gerrit', 'query', '--format=JSON', 'status:%s' % status, 'project:%s' % project, 'branch:%s' % branch)
+ for chunk in lines.strip().split("\n"):
data = loads(chunk)
- #pprint(data)
if 'url' in data.keys():
print data['url'] + " \"" + data['subject'] + "\" " + data['owner']['email']
commit 48cbdd77e1cef40b451c167112957ea5ed0bd6c8
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jun 6 15:14:39 2013 +0200
actually use project and branch
diff --git a/gerritbot/gerrit_daily_digest.py b/gerritbot/gerrit_daily_digest.py
index 163d9e5..59ac20e 100755
--- a/gerritbot/gerrit_daily_digest.py
+++ b/gerritbot/gerrit_daily_digest.py
@@ -30,7 +30,7 @@ def main():
status = args['status']
project = args['project']
branch = args['branch']
- cmd = "ssh " + gerrit_host_name + " gerrit query --format=JSON status:" + status + " project:core branch:master"
+ cmd = 'ssh %s gerrit query --format=JSON status:%s project:%s branch:%s' % (gerrit_host_name, status, project, branch)
lines = check_output(cmd, shell=True, stderr=STDOUT).strip()
for chunk in lines.split("\n"):
data = loads(chunk)
commit 796a1022e56425904149d6fc2fc299da22934923
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jun 6 15:11:43 2013 +0200
add license header, move to argparse
diff --git a/gerritbot/gerrit_daily_digest.py b/gerritbot/gerrit_daily_digest.py
new file mode 100755
index 0000000..163d9e5
--- /dev/null
+++ b/gerritbot/gerrit_daily_digest.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+'''
+Created on 19.06.2012
+
+ at author: david ostrovsky
+'''
+
+from subprocess import check_output, STDOUT
+from json import loads
+import getopt, sys
+import argparse
+#from pprint import pprint
+
+def main():
+ parser = argparse.ArgumentParser('gerrit daily digest generator')
+ parser.add_argument('-s', '--status', choices=['open', 'merged', 'abandoned'], required=True)
+ parser.add_argument('-g', '--gerrit', help='(i. e. logerrit or gerrit.libreoffice.org, use alias in your ~/.ssh(config with your public key)', required=True)
+ parser.add_argument('-p', '--project', help='(i. e. core)', required=True)
+ parser.add_argument('-b', '--branch', help='(i. e. master)', required=True)
+ args=vars(parser.parse_args())
+ gerrit_host_name = args['gerrit']
+ status = args['status']
+ project = args['project']
+ branch = args['branch']
+ cmd = "ssh " + gerrit_host_name + " gerrit query --format=JSON status:" + status + " project:core branch:master"
+ lines = check_output(cmd, shell=True, stderr=STDOUT).strip()
+ for chunk in lines.split("\n"):
+ data = loads(chunk)
+ #pprint(data)
+ if 'url' in data.keys():
+ print data['url'] + " \"" + data['subject'] + "\" " + data['owner']['email']
+
+if __name__ == "__main__":
+ main()
+# vim: set et sw=4 ts=4:
More information about the Libreoffice-commits
mailing list