mirror of
https://github.com/chatmail/core.git
synced 2026-04-05 23:22:11 +03:00
Put emails into the tmp folder
This commit is contained in:
@@ -28,7 +28,7 @@ class Account(object):
|
||||
"""
|
||||
MissingCredentials = MissingCredentials
|
||||
|
||||
def __init__(self, db_path, os_name=None, logging=True):
|
||||
def __init__(self, db_path, os_name=None, logging=True, logid=None):
|
||||
""" initialize account object.
|
||||
|
||||
:param db_path: a path to the account database. The database
|
||||
@@ -38,6 +38,7 @@ class Account(object):
|
||||
# initialize per-account plugin system
|
||||
self._pm = hookspec.PerAccount._make_plugin_manager()
|
||||
self._logging = logging
|
||||
self.logid=logid
|
||||
|
||||
self.add_account_plugin(self)
|
||||
|
||||
|
||||
@@ -94,18 +94,19 @@ def make_direct_imap(account, folder):
|
||||
imap = ImapConn(folder, conn_info=conn_info)
|
||||
return imap
|
||||
|
||||
def print_imap_structure(database):
|
||||
print_imap_structure_ac(Account(database))
|
||||
def print_imap_structure(database, dir="."):
|
||||
print_imap_structure_ac(Account(database), dir)
|
||||
|
||||
def print_imap_structure_ac(ac):
|
||||
print("================= ACCOUNT", ac.get_config("addr"), "=================")
|
||||
def print_imap_structure_ac(ac, dir="."):
|
||||
acinfo = ac.logid + "-" + ac.get_config("addr")
|
||||
print("================= ACCOUNT", acinfo, "=================")
|
||||
print("----------------- CONFIG: -----------------")
|
||||
print(ac.get_info())
|
||||
|
||||
for folder in [INBOX, MVBOX, SENT]:
|
||||
for imapfolder in [INBOX, MVBOX, SENT]:
|
||||
try:
|
||||
print("-----------------", folder, "-----------------")
|
||||
imap = make_direct_imap(ac, folder)
|
||||
print("-----------------", imapfolder, "-----------------")
|
||||
imap = make_direct_imap(ac, imapfolder)
|
||||
c = imap.connection
|
||||
typ, data = c.search(None, 'ALL')
|
||||
c._get_tagged_response
|
||||
@@ -116,10 +117,10 @@ def print_imap_structure_ac(ac):
|
||||
typ, data = c.fetch(num, '(UID FLAGS)')
|
||||
info = data[0]
|
||||
|
||||
path = pathlib.Path("./IMAP-MESSAGES-" + ac.get_config("addr") + "~/" + folder)
|
||||
path = pathlib.Path(dir).joinpath("IMAP-MESSAGES", acinfo, imapfolder)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
file = path.joinpath(str(info).replace("b'", "").replace("'", "").replace("\\", ""))
|
||||
file.write_bytes(body)
|
||||
print("Message", info, "saved as", file)
|
||||
except ConnectionError:
|
||||
print("Seems like there is no", folder, "folder")
|
||||
print("Seems like there is no", imapfolder, "folder")
|
||||
|
||||
@@ -230,7 +230,7 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, data):
|
||||
acc.disable_logging()
|
||||
|
||||
def make_account(self, path, logid, quiet=False):
|
||||
ac = Account(path, logging=self._logging)
|
||||
ac = Account(path, logging=self._logging, logid=logid)
|
||||
ac._evtracker = ac.add_account_plugin(FFIEventTracker(ac))
|
||||
ac.addr = ac.get_self_contact().addr
|
||||
if not quiet:
|
||||
@@ -382,7 +382,7 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, data):
|
||||
yield am
|
||||
if request.node.rep_call.failed:
|
||||
for ac in am._accounts:
|
||||
direct_imap.print_imap_structure_ac(ac)
|
||||
direct_imap.print_imap_structure_ac(ac, tmpdir)
|
||||
|
||||
|
||||
class BotProcess:
|
||||
|
||||
Reference in New Issue
Block a user