unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Python notmuch2 bridge, something changed in the Database constructor
@ 2021-12-24  7:09 Lele Gaifax
  2021-12-24 13:03 ` David Bremner
  2022-01-08 16:19 ` [PATCH] bindings/python-cffi: search for config by default David Bremner
  0 siblings, 2 replies; 8+ messages in thread
From: Lele Gaifax @ 2021-12-24  7:09 UTC (permalink / raw)
  To: notmuch

Hi,

yesterday I found that since some time (sorry, cannot say that more exactly)
my offlineimap's presynchook started to fail, and investigating I have a doubt
about what were wrong.

My script basically looks like this:

  from notmuch2 import Database

  def handle_deleted_messages(db):
      ...

  def move_spam_to_junk(db):
      ...
      
  with Database() as db:
      handle_deleted_messages(db)
      move_spam_to_junk(db)

It surely worked without issue for years, but now I get this:

  >>> from notmuch2 import Database
  >>> db = Database()
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    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?

Thanks in advance and happy xmass everybody!

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it  |                 -- Fortunato Depero, 1929.
\r

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-01-09 20:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24  7:09 Python notmuch2 bridge, something changed in the Database constructor Lele Gaifax
2021-12-24 13:03 ` David Bremner
2021-12-24 13:42   ` Lele Gaifax
2022-01-01 15:20   ` Floris Bruynooghe
2022-01-08 16:19 ` [PATCH] bindings/python-cffi: search for config by default David Bremner
2022-01-08 18:47   ` Floris Bruynooghe
2022-01-08 21:21     ` [PATCH v2] " David Bremner
2022-01-09 20:00       ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).