[PATCH v2] contrib/nmbug: add nmbug-status script
authordavid <david@tethera.net>
Mon, 9 Jul 2012 05:09:06 +0000 (23:09 +1800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:04 +0000 (09:48 -0800)
8b/149676c20b9a4bb297958877a91f0561b6eba2 [new file with mode: 0644]

diff --git a/8b/149676c20b9a4bb297958877a91f0561b6eba2 b/8b/149676c20b9a4bb297958877a91f0561b6eba2
new file mode 100644 (file)
index 0000000..461079c
--- /dev/null
@@ -0,0 +1,290 @@
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id BBADB431FBC\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Jul 2012 22:09:20 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id v7+e3PUe27Ra for <notmuch@notmuchmail.org>;\r
+       Sun,  8 Jul 2012 22:09:18 -0700 (PDT)\r
+Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
+       (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id EC803431FAE\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Jul 2012 22:09:17 -0700 (PDT)\r
+Received: from remotemail by tesseract.cs.unb.ca with local (Exim 4.72)\r
+       (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+       id 1So6Di-0004dM-Ky; Mon, 09 Jul 2012 02:09:14 -0300\r
+Received: (nullmailer pid 29417 invoked by uid 1000);\r
+       Mon, 09 Jul 2012 05:09:08 -0000\r
+From: david@tethera.net\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] contrib/nmbug: add nmbug-status script\r
+Date: Sun,  8 Jul 2012 23:09:06 -0600\r
+Message-Id: <1341810546-28857-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1341689754-15243-2-git-send-email-david@tethera.net>\r
+References: <1341689754-15243-2-git-send-email-david@tethera.net>\r
+Cc: David Bremner <bremner@debian.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 09 Jul 2012 05:09:20 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+This is (almost) the same script as has been used for\r
+http://nmbug.tethera.net/status for a while now. The only change is\r
+that the configuration is not hardcoded anymore. By default the config\r
+is fetched from a special branch in the nmbug repo that contains only\r
+config info. The idea is that push access to this branch can be\r
+restricted a bit more than the tags, since it will change the\r
+appearence of the web pages.\r
+---\r
+\r
+The change here is to extract the configuration from a branch in the\r
+nmbug repo. This will allow multiple people to update the layout of the status page.\r
+\r
+ contrib/nmbug/nmbug-status       |  141 ++++++++++++++++++++++++++++++++++++++\r
+ contrib/nmbug/status-config.json |   65 ++++++++++++++++++\r
+ 2 files changed, 206 insertions(+)\r
+ create mode 100755 contrib/nmbug/nmbug-status\r
+ create mode 100644 contrib/nmbug/status-config.json\r
+\r
+diff --git a/contrib/nmbug/nmbug-status b/contrib/nmbug/nmbug-status\r
+new file mode 100755\r
+index 0000000..cee9d3d\r
+--- /dev/null\r
++++ b/contrib/nmbug/nmbug-status\r
+@@ -0,0 +1,141 @@\r
++#!/usr/bin/python\r
++#\r
++# Copyright (c) 2011-2012 David Bremner <david@tethera.net>\r
++# License: Same as notmuch\r
++# dependencies\r
++#       - python 2.6 for json\r
++#       - argparse; either python 2.7, or install seperately\r
++\r
++import datetime\r
++import notmuch\r
++import sys\r
++import rfc822\r
++import urllib\r
++import json\r
++import argparse\r
++import os\r
++import subprocess\r
++\r
++# parse command line arguments\r
++\r
++parser = argparse.ArgumentParser()\r
++parser.add_argument("--text", help="output plain text format",\r
++                  action="store_true")\r
++\r
++parser.add_argument("--config", help="load config from given file")\r
++\r
++\r
++args = parser.parse_args()\r
++\r
++# read config from json file\r
++\r
++if args.config != None:\r
++    fp = open(args.config)\r
++else:\r
++    nmbhome = os.getenv('NMBGIT',os.path.expanduser("~/.nmbug"))\r
++\r
++    fp =  subprocess.Popen(['git','--git-dir',nmbhome,\r
++                            'cat-file','blob','config:status-config.json'],\r
++                           stdout=subprocess.PIPE).stdout\r
++\r
++config=json.load(fp)\r
++\r
++if args.text:\r
++    format = 'text'\r
++else:\r
++    format = 'html'\r
++\r
++headers = ['date', 'from', 'subject']\r
++last = {}\r
++\r
++def clear_last():\r
++    for header in headers:\r
++      last[header] = ''\r
++\r
++def print_view(title, query, comment):\r
++\r
++    query_string = " and ".join(query)\r
++    q_new = notmuch.Query(db, query_string)\r
++    q_new.set_sort(notmuch.Query.SORT.OLDEST_FIRST)\r
++\r
++\r
++    last['thread_id'] = ''\r
++\r
++    if format == 'html':\r
++      print '<h3>%s</h3>' % title\r
++      print comment\r
++      print 'The view is generated from the following query:'\r
++      print '<blockquote>'\r
++      print query_string\r
++      print '</blockquote>'\r
++      print '<table>\n'\r
++\r
++    for m in q_new.search_messages():\r
++\r
++      out = {};\r
++\r
++      thread_id = m.get_thread_id()\r
++      if thread_id != last['thread_id']:\r
++          clear_last()\r
++\r
++      for header in headers:\r
++          val = m.get_header(header)\r
++\r
++          if header == 'date':\r
++              val = str.join(' ', val.split(None)[1:4])\r
++              val = str(datetime.datetime.strptime(val, '%d %b %Y').date())\r
++          elif header == 'from':\r
++              val = rfc822.parseaddr(val)[0]\r
++\r
++          if last[header] == val:\r
++              out[header] = ""\r
++          else:\r
++              out[header] = val.encode('utf-8')\r
++              last[header] = val\r
++\r
++      mid = m.get_message_id()\r
++      out['id'] = 'id:"%s"' % mid\r
++\r
++      if format == 'html':\r
++          # XXX using <br /> is a hack, but ... // 20111216 too\r
++          if thread_id != last['thread_id']:\r
++              br = '<br />'\r
++          else:\r
++              br = ''\r
++          out['subject'] = '<a href="http://mid.gmane.org/%s">%s</a>' % (urllib.quote(mid), out['subject'])\r
++          print " <tr><td>%s %s" % (br, out['date'])\r
++          print "</td><td>%s %s" % (br, out['id'])\r
++          print "</td></tr>"\r
++          print " <tr><td>%s" % out['from']\r
++          print "</td><td>%s" % out['subject']\r
++          print "</td></tr>\n"\r
++      else:\r
++          print '%(date)-10.10s %(from)-20.20s %(subject)-40.40s\n%(id)72s\n' % out\r
++\r
++      last['thread_id'] = thread_id\r
++\r
++    if format == 'html':\r
++      print '</table>'\r
++\r
++# main program\r
++\r
++db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)\r
++\r
++if format == 'html':\r
++    print '''<?xml version="1.0" encoding="utf-8" ?>\r
++<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
++<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\r
++<head>\r
++<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
++<title>Notmuch Patches</title>\r
++</head>\r
++<body>''';\r
++    print '<h2>Notmuch Patches</h2>'\r
++    print 'Generated: %s<br />' % datetime.datetime.utcnow().date()\r
++    print 'For more infomation see <a href="http://notmuchmail.org/nmbug">nmbug</a>'\r
++\r
++for view in config['views']:\r
++    print_view(**view)\r
++\r
++if format == 'html':\r
++    print '</body>\n</html>'\r
+diff --git a/contrib/nmbug/status-config.json b/contrib/nmbug/status-config.json\r
+new file mode 100644\r
+index 0000000..6b4934f\r
+--- /dev/null\r
++++ b/contrib/nmbug/status-config.json\r
+@@ -0,0 +1,65 @@\r
++{\r
++    "views": [\r
++      {\r
++          "comment": "Unresolved bugs (or just need tag updating).",\r
++          "query": [\r
++              "tag:notmuch::bug",\r
++              "not tag:notmuch::fixed",\r
++              "not tag:notmuch::wontfix"\r
++          ],\r
++          "title": "Bugs"\r
++      },\r
++      {\r
++          "comment": "These patches are under consideration for pushing.",\r
++          "query": [\r
++              "tag:notmuch::patch and not tag:notmuch::pushed",\r
++              "not tag:notmuch::obsolete and not tag:notmuch::wip",\r
++              "not tag:notmuch::stale and not tag:notmuch::contrib",\r
++              "not tag:notmuch::moreinfo",\r
++              "not tag:notmuch::python",\r
++              "not tag:notmuch::vim",\r
++              "not tag:notmuch::wontfix",\r
++              "not tag:notmuch::needs-review"\r
++          ],\r
++          "title": "Maybe Ready (Core and Emacs)"\r
++      },\r
++      {\r
++          "comment": "These python related patches might be ready to push, or they might just need updated tags.",\r
++          "query": [\r
++              "tag:notmuch::patch and not tag:notmuch::pushed",\r
++              "not tag:notmuch::obsolete and not tag:notmuch::wip",\r
++              "not tag:notmuch::stale and not tag:notmuch::contrib",\r
++              "not tag:notmuch::moreinfo",\r
++              "not tag:notmuch::wontfix",\r
++              " tag:notmuch::python",\r
++              "not tag:notmuch::needs-review"\r
++          ],\r
++          "title": "Maybe Ready (Python)"\r
++      },\r
++      {\r
++          "comment": "These vim related patches might be ready to push, or they might just need updated tags.",\r
++          "query": [\r
++              "tag:notmuch::patch and not tag:notmuch::pushed",\r
++              "not tag:notmuch::obsolete and not tag:notmuch::wip",\r
++              "not tag:notmuch::stale and not tag:notmuch::contrib",\r
++              "not tag:notmuch::moreinfo",\r
++              "not tag:notmuch::wontfix",\r
++              "tag:notmuch::vim",\r
++              "not tag:notmuch::needs-review"\r
++          ],\r
++          "title": "Maybe Ready (vim)"\r
++      },\r
++      {\r
++          "comment": "These patches are under review, or waiting for feedback.",\r
++          "query": [\r
++              "tag:notmuch::patch",\r
++              "not tag:notmuch::pushed",\r
++              "not tag:notmuch::obsolete",\r
++              "not tag:notmuch::stale",\r
++              "not tag:notmuch::wontfix",\r
++              "(tag:notmuch::moreinfo or tag:notmuch::needs-review)"\r
++          ],\r
++          "title": "Review"\r
++      }\r
++    ]\r
++}\r
+-- \r
+1.7.10\r
+\r