From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oEUBKCDFxWGVFAEAgWs5BA (envelope-from ) for ; Fri, 24 Dec 2021 14:03:28 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id UBXCIyDFxWE3IQAAB5/wlQ (envelope-from ) for ; Fri, 24 Dec 2021 13:03:28 +0000 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 579C42551F for ; Fri, 24 Dec 2021 14:03:28 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 9DD265F718; Fri, 24 Dec 2021 13:03:24 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 2EB295F713 for ; Fri, 24 Dec 2021 13:03:22 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 756AD5FC42; Fri, 24 Dec 2021 08:03:21 -0500 (EST) Received: (nullmailer pid 2217074 invoked by uid 1000); Fri, 24 Dec 2021 13:03:20 -0000 From: David Bremner To: Lele Gaifax , notmuch@notmuchmail.org Subject: Re: Python notmuch2 bridge, something changed in the Database constructor In-Reply-To: <87fsqijx7u.fsf@metapensiero.it> References: <87fsqijx7u.fsf@metapensiero.it> X-List-To: notmuch Date: Fri, 24 Dec 2021 09:03:20 -0400 Message-ID: <87lf0anoiv.fsf@tethera.net> MIME-Version: 1.0 Message-ID-Hash: SQ6SWMNKFPEHHZ7ZMRB736T5RUBO3PZO X-Message-ID-Hash: SQ6SWMNKFPEHHZ7ZMRB736T5RUBO3PZO X-MailFrom: david@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640351008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=FFSrZh12XCc3xuPBRrw1CbVcWVLY7K0xw9RAn2Fv8lk=; b=M6WjUSRiv0wtEakUm4gOIoB00f91RSBY5LmycbC1IYxs3xooVB1hk48zF2CESh9I4z2AYQ QsFzCMOhRsSdrM0yoVGZ+LrURvwkmRN0n+VOPBrbI/gKH4niA/D8/UFi1Gyq6w6BZa+0Hu ZHcreJBRa2VPs7wn6rbJ2G31/kQc8YPxE6LHcibi/9LLgaNm8Hwwqsjg51pxdt2OCJzJCJ 3H7oTIiTI1b4UZjqWW0zevinVHIuQorYedlnc0cerkEHAuym0jq3kESnwevG9sCMRJeJCE 5CantCCYApJSUnF2YIlUf8qvrlYKebUTe3Ufzib76k+mszH/auT0zLxZxhk/Tg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640351008; a=rsa-sha256; cv=none; b=nP0bIQMGbJYs1ySS6bkWEunbqj+jQXY+cfNJA81edevaompNZtptgV7bdDaqRTzCvinHMo YJl9/8T4ixTih/Hub3gILj+N2wsYJM8q1dHii9lCE9g+QuyQWuq3PuGJ1HFoFMIcDXqnyC ZqZ7m15Q82enDolXn0xPda29viQAMjUmGN8Neo+4Y//BpQ9ZGDnkGsw/K/nwgcYHzfSCS8 JS4fA7nEzlzbFQ2R9NLQHqDte4ApKp0ReRS612Vg5VxJgx9dYJrDRJP89bvIDlyDOdK+zM WCABlWq18L87rADyYO8Uj55n3eOW6sczPN8bJ0NfhZnodFjcBTxG7VkavzOhJA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -3.24 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 579C42551F X-Spam-Score: -3.24 X-Migadu-Scanner: scn0.migadu.com X-TUID: ix0bbJdHezux Lele Gaifax writes: > It surely worked without issue for years, but now I get this: > > >>> from notmuch2 import Database > >>> db = Database() > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python3/dist-packages/notmuch2/_database.py", line 160, in __init__ > raise errors.NotmuchError(ret, msg) > notmuch2.NoDatabaseError: Error: could not locate database. > > even if Database doc still says that the path argument can be omitted: > > | :param path: The directory of where the database is stored. If > | ``None`` the location will be searched according to > | :ref:`database` > > Sure enough the configuration contains a "database" section, and the > default_path() class method is able to look it up: > > >>> Database.default_path() > PosixPath('/home/lele/Maildir') > > so fixed my problem with a minor tweak, ie doing > > with Database(Database.default_path()) as db: > handle_deleted_messages(db) > move_spam_to_junk(db) > > I wonder where the trouble is is: has something changed in the notmuch2 > bridge, or is the Database documentation out of date? Yes there was a change to the Database constructor in the notmuch2 python module in 0.34.2. It now uses the library to search for configuration files and databases, so the semantics are a bit different. But it is also possible that that default for the config argument should be changed. Can you try with Database(config=Database.CONFIG.SEARCH) as db: @Floris: when I made the change to the Database constructor, I chose the default as CONFIG.NONE because this matched the previous semantics _except_ for finding the database path. But since I don't want to use the ad hoc default_path method anymore, maybe a better default would be CONFIG.SEARCH. I guess most users of the python bindings will be OK with the the configuration values in .notmuch-config being loaded by default. What do you think?