1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 29913431FD0
\r
6 for <notmuch@notmuchmail.org>; Sat, 7 Jul 2012 12:36:17 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 4+bi1C5vg8T5 for <notmuch@notmuchmail.org>;
\r
16 Sat, 7 Jul 2012 12:36:15 -0700 (PDT)
\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])
\r
18 (using TLSv1 with cipher AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 3FB15431FC2
\r
21 for <notmuch@notmuchmail.org>; Sat, 7 Jul 2012 12:36:15 -0700 (PDT)
\r
22 Received: from remotemail by tesseract.cs.unb.ca with local (Exim 4.72)
\r
23 (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
24 id 1Snane-0003Rl-NQ; Sat, 07 Jul 2012 16:36:14 -0300
\r
25 Received: (nullmailer pid 15436 invoked by uid 1000);
\r
26 Sat, 07 Jul 2012 19:36:10 -0000
\r
27 From: david@tethera.net
\r
28 To: notmuch@notmuchmail.org
\r
29 Subject: [PATCH 2/2] contrib/nmbug: add nmbug-status script
\r
30 Date: Sat, 7 Jul 2012 13:35:54 -0600
\r
31 Message-Id: <1341689754-15243-2-git-send-email-david@tethera.net>
\r
32 X-Mailer: git-send-email 1.7.10
\r
33 In-Reply-To: <1341689754-15243-1-git-send-email-david@tethera.net>
\r
34 References: <1341689754-15243-1-git-send-email-david@tethera.net>
\r
35 Cc: David Bremner <bremner@debian.org>
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.13
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Sat, 07 Jul 2012 19:36:17 -0000
\r
50 From: David Bremner <bremner@debian.org>
\r
52 This is (almost) the same script as has been used for
\r
53 http://nmbug.tethera.net/status for a while now. The only change is
\r
54 that the configuration is not hardcoded anymore.
\r
56 contrib/nmbug/nmbug-status | 132 ++++++++++++++++++++++++++++++++++++++
\r
57 contrib/nmbug/status-config.json | 65 +++++++++++++++++++
\r
58 2 files changed, 197 insertions(+)
\r
59 create mode 100755 contrib/nmbug/nmbug-status
\r
60 create mode 100644 contrib/nmbug/status-config.json
\r
62 diff --git a/contrib/nmbug/nmbug-status b/contrib/nmbug/nmbug-status
\r
63 new file mode 100755
\r
64 index 0000000..3579d08
\r
66 +++ b/contrib/nmbug/nmbug-status
\r
70 +# Copyright (c) 2011-2012 David Bremner <david@tethera.net>
\r
71 +# License: Same as notmuch
\r
73 +# - python 2.6 for json
\r
74 +# - argparse; either python 2.7, or install seperately
\r
85 +# parse command line arguments
\r
87 +parser = argparse.ArgumentParser()
\r
88 +parser.add_argument("--text", help="output plain text format",
\r
89 + action="store_true")
\r
91 +parser.add_argument("--config", help="load config from given file",
\r
92 + default=os.path.expanduser("~/.nmbug/nmbug/status-config.json"))
\r
94 +args = parser.parse_args()
\r
96 +# read config from json file
\r
98 +fp = open(args.config)
\r
99 +config=json.load(fp)
\r
106 +headers = ['date', 'from', 'subject']
\r
110 + for header in headers:
\r
111 + last[header] = ''
\r
113 +def print_view(title, query, comment):
\r
115 + query_string = " and ".join(query)
\r
116 + q_new = notmuch.Query(db, query_string)
\r
117 + q_new.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
\r
120 + last['thread_id'] = ''
\r
122 + if format == 'html':
\r
123 + print '<h3>%s</h3>' % title
\r
125 + print 'The view is generated from the following query:'
\r
126 + print '<blockquote>'
\r
127 + print query_string
\r
128 + print '</blockquote>'
\r
129 + print '<table>\n'
\r
131 + for m in q_new.search_messages():
\r
135 + thread_id = m.get_thread_id()
\r
136 + if thread_id != last['thread_id']:
\r
139 + for header in headers:
\r
140 + val = m.get_header(header)
\r
142 + if header == 'date':
\r
143 + val = str.join(' ', val.split(None)[1:4])
\r
144 + val = str(datetime.datetime.strptime(val, '%d %b %Y').date())
\r
145 + elif header == 'from':
\r
146 + val = rfc822.parseaddr(val)[0]
\r
148 + if last[header] == val:
\r
151 + out[header] = val.encode('utf-8')
\r
152 + last[header] = val
\r
154 + mid = m.get_message_id()
\r
155 + out['id'] = 'id:"%s"' % mid
\r
157 + if format == 'html':
\r
158 + # XXX using <br /> is a hack, but ... // 20111216 too
\r
159 + if thread_id != last['thread_id']:
\r
163 + out['subject'] = '<a href="http://mid.gmane.org/%s">%s</a>' % (urllib.quote(mid), out['subject'])
\r
164 + print " <tr><td>%s %s" % (br, out['date'])
\r
165 + print "</td><td>%s %s" % (br, out['id'])
\r
166 + print "</td></tr>"
\r
167 + print " <tr><td>%s" % out['from']
\r
168 + print "</td><td>%s" % out['subject']
\r
169 + print "</td></tr>\n"
\r
171 + print '%(date)-10.10s %(from)-20.20s %(subject)-40.40s\n%(id)72s\n' % out
\r
173 + last['thread_id'] = thread_id
\r
175 + if format == 'html':
\r
180 +db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)
\r
182 +if format == 'html':
\r
183 + print '''<?xml version="1.0" encoding="utf-8" ?>
\r
184 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
\r
185 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
\r
187 +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
188 +<title>Notmuch Patches</title>
\r
191 + print '<h2>Notmuch Patches</h2>'
\r
192 + print 'Generated: %s<br />' % datetime.datetime.utcnow().date()
\r
193 + print 'For more infomation see <a href="http://notmuchmail.org/nmbug">nmbug</a>'
\r
195 +for view in config['views']:
\r
196 + print_view(**view)
\r
198 +if format == 'html':
\r
199 + print '</body>\n</html>'
\r
200 diff --git a/contrib/nmbug/status-config.json b/contrib/nmbug/status-config.json
\r
201 new file mode 100644
\r
202 index 0000000..6b4934f
\r
204 +++ b/contrib/nmbug/status-config.json
\r
209 + "comment": "Unresolved bugs (or just need tag updating).",
\r
211 + "tag:notmuch::bug",
\r
212 + "not tag:notmuch::fixed",
\r
213 + "not tag:notmuch::wontfix"
\r
218 + "comment": "These patches are under consideration for pushing.",
\r
220 + "tag:notmuch::patch and not tag:notmuch::pushed",
\r
221 + "not tag:notmuch::obsolete and not tag:notmuch::wip",
\r
222 + "not tag:notmuch::stale and not tag:notmuch::contrib",
\r
223 + "not tag:notmuch::moreinfo",
\r
224 + "not tag:notmuch::python",
\r
225 + "not tag:notmuch::vim",
\r
226 + "not tag:notmuch::wontfix",
\r
227 + "not tag:notmuch::needs-review"
\r
229 + "title": "Maybe Ready (Core and Emacs)"
\r
232 + "comment": "These python related patches might be ready to push, or they might just need updated tags.",
\r
234 + "tag:notmuch::patch and not tag:notmuch::pushed",
\r
235 + "not tag:notmuch::obsolete and not tag:notmuch::wip",
\r
236 + "not tag:notmuch::stale and not tag:notmuch::contrib",
\r
237 + "not tag:notmuch::moreinfo",
\r
238 + "not tag:notmuch::wontfix",
\r
239 + " tag:notmuch::python",
\r
240 + "not tag:notmuch::needs-review"
\r
242 + "title": "Maybe Ready (Python)"
\r
245 + "comment": "These vim related patches might be ready to push, or they might just need updated tags.",
\r
247 + "tag:notmuch::patch and not tag:notmuch::pushed",
\r
248 + "not tag:notmuch::obsolete and not tag:notmuch::wip",
\r
249 + "not tag:notmuch::stale and not tag:notmuch::contrib",
\r
250 + "not tag:notmuch::moreinfo",
\r
251 + "not tag:notmuch::wontfix",
\r
252 + "tag:notmuch::vim",
\r
253 + "not tag:notmuch::needs-review"
\r
255 + "title": "Maybe Ready (vim)"
\r
258 + "comment": "These patches are under review, or waiting for feedback.",
\r
260 + "tag:notmuch::patch",
\r
261 + "not tag:notmuch::pushed",
\r
262 + "not tag:notmuch::obsolete",
\r
263 + "not tag:notmuch::stale",
\r
264 + "not tag:notmuch::wontfix",
\r
265 + "(tag:notmuch::moreinfo or tag:notmuch::needs-review)"
\r
267 + "title": "Review"
\r