[PATCH v2] add notmuch.Database.get_status_string()

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Dec 9 18:16:40 PST 2015


This gives some additional access to debugging information when using
the python bindings.
---
 bindings/python/notmuch/database.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
index 5b58e09..d29c292 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -114,6 +114,11 @@ class Database(object):
     _get_all_tags.argtypes = [NotmuchDatabaseP]
     _get_all_tags.restype = NotmuchTagsP
 
+    """notmuch_database_status_string"""
+    _get_status_string = nmlib.notmuch_database_status_string
+    _get_status_string.argtypes = [NotmuchDatabaseP]
+    _get_status_string.restype = c_char_p
+
     """notmuch_database_create"""
     _create = nmlib.notmuch_database_create
     _create.argtypes = [c_char_p, POINTER(NotmuchDatabaseP)]
@@ -575,6 +580,17 @@ class Database(object):
         """
         return Query(self, querystring)
 
+    def get_status_string(self):
+        """Returns the status string of the database
+
+        This is sometimes used for additional error reporting
+        """
+        self._assert_db_is_initialized()
+        s = Database._get_status_string(self._db)
+        if s:
+            return s.decode('utf-8', 'ignore')
+        return s
+
     def __repr__(self):
         return "'Notmuch DB " + self.get_path() + "'"
 
-- 
2.6.2



More information about the notmuch mailing list