diff options
Diffstat (limited to 'script')
-rwxr-xr-x | script/extract.py | 6 | ||||
-rwxr-xr-x | script/moveto3.py | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/script/extract.py b/script/extract.py index a54f992..3a3a17c 100755 --- a/script/extract.py +++ b/script/extract.py @@ -30,6 +30,7 @@ import re from argparse import ArgumentParser from base64 import b64encode from datetime import datetime +from email.message import EmailMessage from itertools import islice from mailbox import Maildir, MaildirMessage from os import environ, getpid, path, setuid @@ -395,9 +396,10 @@ def raw_mail(f, req): if hasattr(b, "__next__"): raise QMAuthError("can not stop at multipart section", path=pth) - - if isinstance(b, str): + elif isinstance(b, str): b = b.encode() + elif isinstance(b, EmailMessage): + b = b.as_bytes() return jwebmail.RawResp(header=h, body=b).SerializeToString() diff --git a/script/moveto3.py b/script/moveto3.py index fba5ddd..408ff1a 100755 --- a/script/moveto3.py +++ b/script/moveto3.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import argparse import os -import sys def main(): @@ -9,12 +8,12 @@ def main(): ap.add_argument("-a", default="qmail-authuser", dest="pam") ap.add_argument("fd", type=int) ap.add_argument("prog") - ap.add_argument("args", nargs='*') + ap.add_argument("args", nargs="*") vals = ap.parse_args() if vals.fd < 3: - raise ValueError(f"fd({fd}) must be 3 or greater") + raise ValueError(f"fd({vals.fd}) must be 3 or greater") if vals.fd != 3: os.dup2(vals.fd, 3) @@ -25,5 +24,5 @@ def main(): raise ValueError("should not be reachable") -if __name__ == '__main__': +if __name__ == "__main__": main() |