Browse Source

print more

master
Volker Birk 6 years ago
parent
commit
b5c07f0bea
  1. 1
      test/minimail.py
  2. 29
      test/sync_handshake.py

1
test/minimail.py

@ -53,6 +53,7 @@ class Lock:
def send(inbox, msg, marker): def send(inbox, msg, marker):
"send msg to inbox in MIME format" "send msg to inbox in MIME format"
sleep(1)
with Lock(inbox): with Lock(inbox):
name = marker + "_" + token_urlsafe(16) + ".eml" name = marker + "_" + token_urlsafe(16) + ".eml"
with open(inbox / name, "wb") as f: with open(inbox / name, "wb") as f:

29
test/sync_handshake.py

@ -48,17 +48,24 @@ SYNC_HANDSHAKE_REJECTED = 1
def print_msg(p): def print_msg(p):
if p.name[:5] == "Phone": if isinstance(p, pathlib.Path):
color = "red" if p.name[:5] == "Phone":
elif p.name[:6] == "Laptop": color = "red"
color = "green" 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: else:
color = "lightblue" raise TypeError("print_msg(): pathlib.Path and pEp.Message supported, but "
with open(p, "r") as f: + str(type(p)) + " delivered")
t = f.read(-1)
msg = pEp.Message(t)
print("\n" + colored(p.name, color))
print(colored(str(datetime.fromtimestamp(p.stat().st_mtime)), color))
m = re.search("<keysync>(.*)</keysync>", msg.opt_fields["pEp.sync"].replace("\n", " ")) m = re.search("<keysync>(.*)</keysync>", msg.opt_fields["pEp.sync"].replace("\n", " "))
if m: if m:
if etree: if etree:
@ -113,6 +120,8 @@ def run(name, color=None):
l = minimail.recv_all(inbox, name) l = minimail.recv_all(inbox, name)
for n, m in l: for n, m in l:
msg = pEp.Message(m) msg = pEp.Message(m)
print(colored("*** Reading", color))
print_msg(msg)
msg2, keys, rating, flags = msg.decrypt() msg2, keys, rating, flags = msg.decrypt()
except KeyboardInterrupt: except KeyboardInterrupt:

Loading…
Cancel
Save