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 BBADB431FBC
\r
6 for <notmuch@notmuchmail.org>; Sun, 8 Jul 2012 22:09:20 -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 v7+e3PUe27Ra for <notmuch@notmuchmail.org>;
\r
16 Sun, 8 Jul 2012 22:09:18 -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 EC803431FAE
\r
21 for <notmuch@notmuchmail.org>; Sun, 8 Jul 2012 22:09:17 -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 1So6Di-0004dM-Ky; Mon, 09 Jul 2012 02:09:14 -0300
\r
25 Received: (nullmailer pid 29417 invoked by uid 1000);
\r
26 Mon, 09 Jul 2012 05:09:08 -0000
\r
27 From: david@tethera.net
\r
28 To: notmuch@notmuchmail.org
\r
29 Subject: [PATCH v2] contrib/nmbug: add nmbug-status script
\r
30 Date: Sun, 8 Jul 2012 23:09:06 -0600
\r
31 Message-Id: <1341810546-28857-1-git-send-email-david@tethera.net>
\r
32 X-Mailer: git-send-email 1.7.10
\r
33 In-Reply-To: <1341689754-15243-2-git-send-email-david@tethera.net>
\r
34 References: <1341689754-15243-2-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: Mon, 09 Jul 2012 05:09:20 -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. By default the config
\r
55 is fetched from a special branch in the nmbug repo that contains only
\r
56 config info. The idea is that push access to this branch can be
\r
57 restricted a bit more than the tags, since it will change the
\r
58 appearence of the web pages.
\r
61 The change here is to extract the configuration from a branch in the
\r
62 nmbug repo. This will allow multiple people to update the layout of the status page.
\r
64 contrib/nmbug/nmbug-status | 141 ++++++++++++++++++++++++++++++++++++++
\r
65 contrib/nmbug/status-config.json | 65 ++++++++++++++++++
\r
66 2 files changed, 206 insertions(+)
\r
67 create mode 100755 contrib/nmbug/nmbug-status
\r
68 create mode 100644 contrib/nmbug/status-config.json
\r
70 diff --git a/contrib/nmbug/nmbug-status b/contrib/nmbug/nmbug-status
\r
71 new file mode 100755
\r
72 index 0000000..cee9d3d
\r
74 +++ b/contrib/nmbug/nmbug-status
\r
78 +# Copyright (c) 2011-2012 David Bremner <david@tethera.net>
\r
79 +# License: Same as notmuch
\r
81 +# - python 2.6 for json
\r
82 +# - argparse; either python 2.7, or install seperately
\r
94 +# parse command line arguments
\r
96 +parser = argparse.ArgumentParser()
\r
97 +parser.add_argument("--text", help="output plain text format",
\r
98 + action="store_true")
\r
100 +parser.add_argument("--config", help="load config from given file")
\r
103 +args = parser.parse_args()
\r
105 +# read config from json file
\r
107 +if args.config != None:
\r
108 + fp = open(args.config)
\r
110 + nmbhome = os.getenv('NMBGIT',os.path.expanduser("~/.nmbug"))
\r
112 + fp = subprocess.Popen(['git','--git-dir',nmbhome,
\r
113 + 'cat-file','blob','config:status-config.json'],
\r
114 + stdout=subprocess.PIPE).stdout
\r
116 +config=json.load(fp)
\r
123 +headers = ['date', 'from', 'subject']
\r
127 + for header in headers:
\r
128 + last[header] = ''
\r
130 +def print_view(title, query, comment):
\r
132 + query_string = " and ".join(query)
\r
133 + q_new = notmuch.Query(db, query_string)
\r
134 + q_new.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
\r
137 + last['thread_id'] = ''
\r
139 + if format == 'html':
\r
140 + print '<h3>%s</h3>' % title
\r
142 + print 'The view is generated from the following query:'
\r
143 + print '<blockquote>'
\r
144 + print query_string
\r
145 + print '</blockquote>'
\r
146 + print '<table>\n'
\r
148 + for m in q_new.search_messages():
\r
152 + thread_id = m.get_thread_id()
\r
153 + if thread_id != last['thread_id']:
\r
156 + for header in headers:
\r
157 + val = m.get_header(header)
\r
159 + if header == 'date':
\r
160 + val = str.join(' ', val.split(None)[1:4])
\r
161 + val = str(datetime.datetime.strptime(val, '%d %b %Y').date())
\r
162 + elif header == 'from':
\r
163 + val = rfc822.parseaddr(val)[0]
\r
165 + if last[header] == val:
\r
168 + out[header] = val.encode('utf-8')
\r
169 + last[header] = val
\r
171 + mid = m.get_message_id()
\r
172 + out['id'] = 'id:"%s"' % mid
\r
174 + if format == 'html':
\r
175 + # XXX using <br /> is a hack, but ... // 20111216 too
\r
176 + if thread_id != last['thread_id']:
\r
180 + out['subject'] = '<a href="http://mid.gmane.org/%s">%s</a>' % (urllib.quote(mid), out['subject'])
\r
181 + print " <tr><td>%s %s" % (br, out['date'])
\r
182 + print "</td><td>%s %s" % (br, out['id'])
\r
183 + print "</td></tr>"
\r
184 + print " <tr><td>%s" % out['from']
\r
185 + print "</td><td>%s" % out['subject']
\r
186 + print "</td></tr>\n"
\r
188 + print '%(date)-10.10s %(from)-20.20s %(subject)-40.40s\n%(id)72s\n' % out
\r
190 + last['thread_id'] = thread_id
\r
192 + if format == 'html':
\r
197 +db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)
\r
199 +if format == 'html':
\r
200 + print '''<?xml version="1.0" encoding="utf-8" ?>
\r
201 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
\r
202 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
\r
204 +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
205 +<title>Notmuch Patches</title>
\r
208 + print '<h2>Notmuch Patches</h2>'
\r
209 + print 'Generated: %s<br />' % datetime.datetime.utcnow().date()
\r
210 + print 'For more infomation see <a href="http://notmuchmail.org/nmbug">nmbug</a>'
\r
212 +for view in config['views']:
\r
213 + print_view(**view)
\r
215 +if format == 'html':
\r
216 + print '</body>\n</html>'
\r
217 diff --git a/contrib/nmbug/status-config.json b/contrib/nmbug/status-config.json
\r
218 new file mode 100644
\r
219 index 0000000..6b4934f
\r
221 +++ b/contrib/nmbug/status-config.json
\r
226 + "comment": "Unresolved bugs (or just need tag updating).",
\r
228 + "tag:notmuch::bug",
\r
229 + "not tag:notmuch::fixed",
\r
230 + "not tag:notmuch::wontfix"
\r
235 + "comment": "These patches are under consideration for pushing.",
\r
237 + "tag:notmuch::patch and not tag:notmuch::pushed",
\r
238 + "not tag:notmuch::obsolete and not tag:notmuch::wip",
\r
239 + "not tag:notmuch::stale and not tag:notmuch::contrib",
\r
240 + "not tag:notmuch::moreinfo",
\r
241 + "not tag:notmuch::python",
\r
242 + "not tag:notmuch::vim",
\r
243 + "not tag:notmuch::wontfix",
\r
244 + "not tag:notmuch::needs-review"
\r
246 + "title": "Maybe Ready (Core and Emacs)"
\r
249 + "comment": "These python related patches might be ready to push, or they might just need updated tags.",
\r
251 + "tag:notmuch::patch and not tag:notmuch::pushed",
\r
252 + "not tag:notmuch::obsolete and not tag:notmuch::wip",
\r
253 + "not tag:notmuch::stale and not tag:notmuch::contrib",
\r
254 + "not tag:notmuch::moreinfo",
\r
255 + "not tag:notmuch::wontfix",
\r
256 + " tag:notmuch::python",
\r
257 + "not tag:notmuch::needs-review"
\r
259 + "title": "Maybe Ready (Python)"
\r
262 + "comment": "These vim related patches might be ready to push, or they might just need updated tags.",
\r
264 + "tag:notmuch::patch and not tag:notmuch::pushed",
\r
265 + "not tag:notmuch::obsolete and not tag:notmuch::wip",
\r
266 + "not tag:notmuch::stale and not tag:notmuch::contrib",
\r
267 + "not tag:notmuch::moreinfo",
\r
268 + "not tag:notmuch::wontfix",
\r
269 + "tag:notmuch::vim",
\r
270 + "not tag:notmuch::needs-review"
\r
272 + "title": "Maybe Ready (vim)"
\r
275 + "comment": "These patches are under review, or waiting for feedback.",
\r
277 + "tag:notmuch::patch",
\r
278 + "not tag:notmuch::pushed",
\r
279 + "not tag:notmuch::obsolete",
\r
280 + "not tag:notmuch::stale",
\r
281 + "not tag:notmuch::wontfix",
\r
282 + "(tag:notmuch::moreinfo or tag:notmuch::needs-review)"
\r
284 + "title": "Review"
\r