diff --git a/test/minimail.py b/test/minimail.py index d121aff..9733fd7 100644 --- a/test/minimail.py +++ b/test/minimail.py @@ -53,6 +53,7 @@ class Lock: def send(inbox, msg, marker): "send msg to inbox in MIME format" + sleep(1) with Lock(inbox): name = marker + "_" + token_urlsafe(16) + ".eml" with open(inbox / name, "wb") as f: diff --git a/test/sync_handshake.py b/test/sync_handshake.py index 287fc0d..32a65a0 100644 --- a/test/sync_handshake.py +++ b/test/sync_handshake.py @@ -48,17 +48,24 @@ SYNC_HANDSHAKE_REJECTED = 1 def print_msg(p): - if p.name[:5] == "Phone": - color = "red" - elif p.name[:6] == "Laptop": - color = "green" + if isinstance(p, pathlib.Path): + if p.name[:5] == "Phone": + color = "red" + elif p.name[:6] == "Laptop": + color = "green" + else: + color = "lightblue" + with open(p, "r") as f: + t = f.read(-1) + msg = pEp.Message(t) + print("\n" + colored(p.name, color)) + print(colored(str(datetime.fromtimestamp(p.stat().st_mtime)), color)) + elif isinstance(p, pEp.Message): + msg = p else: - color = "lightblue" - with open(p, "r") as f: - t = f.read(-1) - msg = pEp.Message(t) - print("\n" + colored(p.name, color)) - print(colored(str(datetime.fromtimestamp(p.stat().st_mtime)), color)) + raise TypeError("print_msg(): pathlib.Path and pEp.Message supported, but " + + str(type(p)) + " delivered") + m = re.search("(.*)", msg.opt_fields["pEp.sync"].replace("\n", " ")) if m: if etree: @@ -113,6 +120,8 @@ def run(name, color=None): l = minimail.recv_all(inbox, name) for n, m in l: msg = pEp.Message(m) + print(colored("*** Reading", color)) + print_msg(msg) msg2, keys, rating, flags = msg.decrypt() except KeyboardInterrupt: