mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 06:56:29 +03:00
Add make_direct_imap() fn. I had to disable PersistentDict because I had problems with importing.
This commit is contained in:
@@ -17,6 +17,9 @@ from .capi import lib
|
||||
from .events import FFIEventLogger, FFIEventTracker
|
||||
from _pytest._code import Source
|
||||
|
||||
import direct_imap
|
||||
from direct_imap import ImapConn
|
||||
|
||||
import deltachat
|
||||
|
||||
|
||||
@@ -375,6 +378,13 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, data):
|
||||
self._finalizers.append(bot.kill)
|
||||
return bot
|
||||
|
||||
def make_direct_imap(self, account, folder):
|
||||
conn_info = (account.get_config("configured_mail_server"),
|
||||
account.get_config("addr"), account.get_config("mail_pw"))
|
||||
imap = ImapConn(None, folder, conn_info=conn_info)
|
||||
imap.connect()
|
||||
return imap
|
||||
|
||||
am = AccountMaker()
|
||||
request.addfinalizer(am.finalize)
|
||||
return am
|
||||
|
||||
@@ -8,7 +8,7 @@ from imapclient import IMAPClient
|
||||
from imapclient.exceptions import IMAPClientError
|
||||
import contextlib
|
||||
import time
|
||||
from persistentdict import PersistentDict
|
||||
#from persistentdict import PersistentDict
|
||||
|
||||
|
||||
INBOX = "INBOX"
|
||||
@@ -41,9 +41,12 @@ class ImapConn(object):
|
||||
self.event_initial_polling_complete = threading.Event()
|
||||
self.pending_imap_jobs = False
|
||||
|
||||
# persistent database state below
|
||||
self.db_folder = self.db.setdefault(foldername, {})
|
||||
self.db_messages = self.db.setdefault(":message-full", {})
|
||||
if not db is None:
|
||||
# persistent database state below
|
||||
self.db_folder = self.db.setdefault(foldername, {})
|
||||
self.db_messages = self.db.setdefault(":message-full", {})
|
||||
else:
|
||||
self.db_messages = {}
|
||||
|
||||
last_sync_uid = db_folder_attr("last_sync_uid")
|
||||
|
||||
@@ -185,7 +188,8 @@ class ImapConn(object):
|
||||
self.last_sync_uid = max(uid, self.last_sync_uid)
|
||||
|
||||
self.log("last-sync-uid after fetch:", self.last_sync_uid)
|
||||
self.db.sync()
|
||||
if not self.db is None:
|
||||
self.db.sync()
|
||||
|
||||
def resolve_move_status(self, msg):
|
||||
""" Return move-state after this message's next move-state is determined (i.e. it is not PENDING)"""
|
||||
@@ -360,9 +364,10 @@ def main(context, basedir, name, imaphost, login_user, login_password, pendingti
|
||||
os.makedirs(basedir)
|
||||
if name is None:
|
||||
name = login_user
|
||||
dbpath = os.path.join(basedir, name) + ".db"
|
||||
print("Using dbfile:", dbpath)
|
||||
db = PersistentDict(dbpath)
|
||||
# dbpath = os.path.join(basedir, name) + ".db"
|
||||
# print("Using dbfile:", dbpath)
|
||||
# db = PersistentDict(dbpath)
|
||||
db = None
|
||||
conn_info = (imaphost, login_user, login_password)
|
||||
inbox = ImapConn(db, INBOX, conn_info=conn_info)
|
||||
inbox.connect()
|
||||
|
||||
Reference in New Issue
Block a user