From 0520174bf3bea71cb38560191f29450f9c3e1826 Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Tue, 13 Jun 2023 16:13:30 -0400 Subject: [PATCH] fixes after manual test --- Makefile | 3 +++ mail4one/config.py | 17 +++++++++-------- mail4one/server.py | 12 ++++++------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index fecf2eb..75aed67 100644 --- a/Makefile +++ b/Makefile @@ -2,3 +2,6 @@ shell: MYPYPATH=`pipenv --venv`/lib/python3.11/site-packages pipenv shell + +test: + pipenv run python -m unittest mail4one/*test.py diff --git a/mail4one/config.py b/mail4one/config.py index 1fde754..1b30710 100644 --- a/mail4one/config.py +++ b/mail4one/config.py @@ -42,6 +42,7 @@ class TLSCfg(Jata): class ServerCfg(Jata): host: str = "default" port: int + # disabled: bool = False tls: TLSCfg | str = "default" @@ -63,16 +64,16 @@ class SmtpCfg(ServerCfg): class Config(Jata): default_tls: TLSCfg | None default_host: str = '0.0.0.0' - - mails_path: str - users: list[User] - boxes: list[Mbox] - matches: list[Match] debug: bool = False - pop: PopCfg | None - smtp_starttls: SmtpStartTLSCfg | None - smtp: SmtpCfg | None + mails_path: str + matches: list[Match] + boxes: list[Mbox] + users: list[User] + + pop: PopCfg | None = None + smtp_starttls: SmtpStartTLSCfg | None = None + smtp: SmtpCfg | None = None # smtp_port_submission = 587 diff --git a/mail4one/server.py b/mail4one/server.py index 046c8a5..9069905 100644 --- a/mail4one/server.py +++ b/mail4one/server.py @@ -85,22 +85,22 @@ async def a_main(cfg: config.Config) -> None: servers.append(smtp_server) if servers: - await asyncio.gather(server.serve_forever() for server in servers) + await asyncio.gather(*[server.serve_forever() for server in servers]) else: logging.warn("Nothing to do!") -def main(): +def main() -> None: parser = ArgumentParser() parser.add_argument("config_path", type=Path) args = parser.parse_args() - config = Config(args.config_path.read_text()) + cfg = config.Config(args.config_path.read_text()) - setup_logging(args) + setup_logging(cfg) loop = asyncio.get_event_loop() - loop.set_debug(config.debug) + loop.set_debug(cfg.debug) - asyncio.run(a_main(config)) + asyncio.run(a_main(cfg)) if __name__ == '__main__':