From 771a69afa0bcd5c2a53155a81ac022ad54ebb6b7 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Mon, 14 May 2012 19:36:11 +2000 Subject: [PATCH] [PATCH v2 3/5] python: Update for changes to notmuch_database_get_directory --- af/ace3961e36dd9e54089500e0edbca4d8d3329e | 130 ++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 af/ace3961e36dd9e54089500e0edbca4d8d3329e diff --git a/af/ace3961e36dd9e54089500e0edbca4d8d3329e b/af/ace3961e36dd9e54089500e0edbca4d8d3329e new file mode 100644 index 000000000..5a1ac94fc --- /dev/null +++ b/af/ace3961e36dd9e54089500e0edbca4d8d3329e @@ -0,0 +1,130 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 24337431FD2 + for ; Sun, 13 May 2012 16:36:27 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id loPIorvo0PyR for ; + Sun, 13 May 2012 16:36:25 -0700 (PDT) +Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU + [18.7.68.35]) + by olra.theworths.org (Postfix) with ESMTP id EC220431FBF + for ; Sun, 13 May 2012 16:36:23 -0700 (PDT) +X-AuditID: 12074423-b7fcc6d0000008a8-da-4fb0457774f6 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP + id EE.F8.02216.77540BF4; Sun, 13 May 2012 19:36:23 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q4DNaLRW009043; + Sun, 13 May 2012 19:36:22 -0400 +Received: from drake.mit.edu + (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [209.6.116.242]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4DNaKmL001098 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sun, 13 May 2012 19:36:21 -0400 (EDT) +Received: from amthrax by drake.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1STiKq-0004YP-4d; Sun, 13 May 2012 19:36:20 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2 3/5] python: Update for changes to + notmuch_database_get_directory +Date: Sun, 13 May 2012 19:36:11 -0400 +Message-Id: <1336952173-17422-4-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1336952173-17422-1-git-send-email-amdragon@mit.edu> +References: <1336939029-13969-1-git-send-email-amdragon@mit.edu> + <1336952173-17422-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsUixG6nrlvuusHfYNIzPYvZrT+YLG60djNa + NE13trh+cyazxZuV81gdWD0Of13I4jHx/Gk2j1v3X7N7PFt1i9ljy6H3zAGsUVw2Kak5mWWp + Rfp2CVwZs6dvZym4JVjRfHQucwPjbt4uRk4OCQETiW19N9ghbDGJC/fWs3UxcnEICexjlPi1 + 4A4ThLOBUWLn6jZGCOc+k8T97u2sEM4sRol9nb9ZQPrZBDQktu1fzghiiwhIS+y8OxusiFmg + i1Hi95tmZpCEsECIRNOpE2wgNouAqsTdXfPAbF4BB4l7PzoZIQ6Rl3h6vw8szingKNH34CPY + gUIC5RIz2q+zTGDkX8DIsIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjXTC83s0QvNaV0EyM4EF2U + dzD+Oah0iFGAg1GJh/el6QZ/IdbEsuLK3EOMkhxMSqK8TE5AIb6k/JTKjMTijPii0pzU4kOM + EhzMSiK86x+u9xfiTUmsrEotyodJSXOwKInzami98xMSSE8sSc1OTS1ILYLJynBwKEnwLnYB + GipYlJqeWpGWmVOCkGbi4AQZzgM0/AxIDW9xQWJucWY6RP4Uoy7Hn4eLrjEKseTl56VKifPO + ACkSACnKKM2DmwNLIK8YxYHeEubdC1LFA0w+cJNeAS1hAlrCL7AOZElJIkJKqoGxLrbt74WJ + s5IevfaQW6iksoyrSuNQr6S89IHXDfqCE+aZ1v1oOfDI8WyN6aGlkf8jb87yfGpjYvWvg/nZ + FIn/bu0TP76KZV+lWhuea1KgPNPkYnCeW2z3zSUff6WuTFGcGh17f8a6F5fqbL13fF9WPWHZ + FAb/Z78OJW04Lu1n9uuURaaR6+leJZbijERDLeai4kQA3EUqCfsCAAA= +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 13 May 2012 23:36:27 -0000 + +notmuch_database_get_directory now returns +NOTMUCH_STATUS_READ_ONLY_DATABASE on its own (rather than crashing) so +the workaround in Database.get_directory is no longer necessary. +--- + bindings/python/notmuch/database.py | 19 +++++++++---------- + 1 file changed, 9 insertions(+), 10 deletions(-) + +diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py +index 1b1ddc3..797554d 100644 +--- a/bindings/python/notmuch/database.py ++++ b/bindings/python/notmuch/database.py +@@ -73,8 +73,8 @@ class Database(object): + + """notmuch_database_get_directory""" + _get_directory = nmlib.notmuch_database_get_directory +- _get_directory.argtypes = [NotmuchDatabaseP, c_char_p] +- _get_directory.restype = NotmuchDirectoryP ++ _get_directory.argtypes = [NotmuchDatabaseP, c_char_p, POINTER(NotmuchDirectoryP)] ++ _get_directory.restype = c_uint + + """notmuch_database_get_path""" + _get_path = nmlib.notmuch_database_get_path +@@ -359,13 +359,6 @@ class Database(object): + """ + self._assert_db_is_initialized() + +- # work around libnotmuch calling exit(3), see +- # id:20120221002921.8534.57091@thinkbox.jade-hamburg.de +- # TODO: remove once this issue is resolved +- if self.mode != Database.MODE.READ_WRITE: +- raise ReadOnlyDatabaseError('The database has to be opened in ' +- 'read-write mode for get_directory') +- + # sanity checking if path is valid, and make path absolute + if path and path[0] == os.sep: + # we got an absolute path +@@ -378,7 +371,13 @@ class Database(object): + #we got a relative path, make it absolute + abs_dirpath = os.path.abspath(os.path.join(self.get_path(), path)) + +- dir_p = Database._get_directory(self._db, _str(path)) ++ dir_p = NotmuchDirectoryP() ++ status = Database._get_directory(self._db, _str(path), byref(dir_p)) ++ ++ if status != STATUS.SUCCESS: ++ raise NotmuchError(status) ++ if not dir_p: ++ return None + + # return the Directory, init it with the absolute path + return Directory(abs_dirpath, dir_p, self) +-- +1.7.10 + -- 2.26.2