diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index b4685659f..36c05b255 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -89,6 +89,22 @@ class Account(object): d[key.lower()] = value return d + def dump_account_info(self, logfile): + def log(*args, **kwargs): + kwargs["file"] = logfile + print(*args, **kwargs) + + log("=============== " + self.get_config("displayname") + " ===============") + cursor = 0 + for name, val in self.get_info().items(): + entry = "{}={}".format(name.upper(), val) + if cursor + len(entry) > 80: + log("") + cursor = 0 + log(entry, end=" ") + cursor += len(entry) + 1 + log("") + def set_stock_translation(self, id, string): """ set stock translation string. diff --git a/python/src/deltachat/direct_imap.py b/python/src/deltachat/direct_imap.py index 3462169f7..2da790869 100644 --- a/python/src/deltachat/direct_imap.py +++ b/python/src/deltachat/direct_imap.py @@ -47,8 +47,9 @@ def dc_account_extra_configure(account): except Exception as e: # Uncaught exceptions here would lead to a timeout without any note written to the log - account.log("=============================== CAN'T RESET ACCOUNT: ===============================") - account.log("===================", e, "===================") + # start with DC_EVENT_WARNING so that the line is printed in yellow and won't be overlooked when reading + account.log("DC_EVENT_WARNING =================== DIRECT_IMAP CAN'T RESET ACCOUNT: ===================") + account.log("DC_EVENT_WARNING =================== " + str(e) + " ===================") @deltachat.global_hookimpl @@ -172,21 +173,6 @@ class DirectImap: def get_unread_cnt(self): return len(self.get_unread_messages()) - def dump_account_info(self, logfile): - def log(*args, **kwargs): - kwargs["file"] = logfile - print(*args, **kwargs) - - cursor = 0 - for name, val in self.account.get_info().items(): - entry = "{}={}".format(name.upper(), val) - if cursor + len(entry) > 80: - log("") - cursor = 0 - log(entry, end=" ") - cursor += len(entry) + 1 - log("") - def dump_imap_structures(self, dir, logfile): assert not self._idling stream = io.StringIO() diff --git a/python/src/deltachat/testplugin.py b/python/src/deltachat/testplugin.py index 29f21bcdd..eecc0133a 100644 --- a/python/src/deltachat/testplugin.py +++ b/python/src/deltachat/testplugin.py @@ -414,13 +414,13 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, data): def dump_imap_summary(self, logfile): for ac in self._accounts: + ac.dump_account_info(logfile=logfile) imap = getattr(ac, "direct_imap", None) if imap is not None: try: imap.idle_done() except Exception: pass - imap.dump_account_info(logfile=logfile) imap.dump_imap_structures(tmpdir, logfile=logfile) def get_accepted_chat(self, ac1, ac2): diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 4098ced63..383bfe555 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -1572,6 +1572,12 @@ class TestOnlineAccount: original_image_path = data.get_path("d.png") chat1.send_image(original_image_path) + # Add another 100KB file that ensures that the progress is smooth enough + path = tmpdir.join("attachment.txt") + with open(path, "w") as file: + file.truncate(100_000) + chat1.send_file(path.strpath) + def assert_account_is_proper(ac): contacts = ac.get_contacts(query="some1") assert len(contacts) == 1 @@ -1579,7 +1585,7 @@ class TestOnlineAccount: assert contact2.addr == "some1@example.org" chat2 = contact2.create_chat() messages = chat2.get_messages() - assert len(messages) == 2 + assert len(messages) == 3 assert messages[0].text == "msg1" assert messages[1].filemime == "image/png" assert os.stat(messages[1].filename).st_size == os.stat(original_image_path).st_size