fixes after manual test

This commit is contained in:
Balakrishnan Balasubramanian 2023-06-13 16:13:30 -04:00
parent 53a275605f
commit 0520174bf3
3 changed files with 18 additions and 14 deletions

View File

@ -2,3 +2,6 @@
shell:
MYPYPATH=`pipenv --venv`/lib/python3.11/site-packages pipenv shell
test:
pipenv run python -m unittest mail4one/*test.py

View File

@ -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

View File

@ -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__':