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