support old python - 3.9
This commit is contained in:
parent
59abf24ce5
commit
5f56a1256b
1
Makefile
1
Makefile
@ -9,6 +9,7 @@ docker-tests:
|
|||||||
docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.10-alpine sh runtests.sh
|
docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.10-alpine sh runtests.sh
|
||||||
docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.11 sh runtests.sh
|
docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.11 sh runtests.sh
|
||||||
docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.10 sh runtests.sh
|
docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.10 sh runtests.sh
|
||||||
|
docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.9 sh runtests.sh
|
||||||
|
|
||||||
requirements.txt: Pipfile.lock
|
requirements.txt: Pipfile.lock
|
||||||
pipenv requirements > requirements.txt
|
pipenv requirements > requirements.txt
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
from typing import Callable
|
from typing import Callable, Union, Optional
|
||||||
from jata import Jata, MutableDefault
|
from jata import Jata, MutableDefault
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class ServerCfg(Jata):
|
|||||||
host: str = "default"
|
host: str = "default"
|
||||||
port: int
|
port: int
|
||||||
# disabled: bool = False
|
# disabled: bool = False
|
||||||
tls: TLSCfg | str = "default"
|
tls: Union[TLSCfg, str] = "default"
|
||||||
|
|
||||||
|
|
||||||
class PopCfg(ServerCfg):
|
class PopCfg(ServerCfg):
|
||||||
@ -72,9 +72,9 @@ class LogCfg(Jata):
|
|||||||
|
|
||||||
|
|
||||||
class Config(Jata):
|
class Config(Jata):
|
||||||
default_tls: TLSCfg | None
|
default_tls: Optional[TLSCfg] = None
|
||||||
default_host: str = "0.0.0.0"
|
default_host: str = "0.0.0.0"
|
||||||
logging: LogCfg | None = None
|
logging: Optional[LogCfg] = None
|
||||||
|
|
||||||
mails_path: str
|
mails_path: str
|
||||||
matches: list[Match]
|
matches: list[Match]
|
||||||
|
@ -13,6 +13,8 @@ from .pwhash import parse_hash, check_pass, PWInfo
|
|||||||
from asyncio import StreamReader, StreamWriter
|
from asyncio import StreamReader, StreamWriter
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from .poputils import (
|
from .poputils import (
|
||||||
InvalidCommand,
|
InvalidCommand,
|
||||||
parse_command,
|
parse_command,
|
||||||
@ -361,7 +363,7 @@ async def create_pop_server(
|
|||||||
port: int,
|
port: int,
|
||||||
mails_path: Path,
|
mails_path: Path,
|
||||||
users: list[User],
|
users: list[User],
|
||||||
ssl_context: ssl.SSLContext | None = None,
|
ssl_context: Optional[ssl.SSLContext] = None,
|
||||||
timeout_seconds: int = 60,
|
timeout_seconds: int = 60,
|
||||||
) -> asyncio.Server:
|
) -> asyncio.Server:
|
||||||
logging.info(
|
logging.info(
|
||||||
|
@ -13,6 +13,7 @@ from .version import VERSION
|
|||||||
|
|
||||||
from . import config
|
from . import config
|
||||||
from . import pwhash
|
from . import pwhash
|
||||||
|
from typing import Optional, Union
|
||||||
|
|
||||||
|
|
||||||
def create_tls_context(certfile, keyfile) -> ssl.SSLContext:
|
def create_tls_context(certfile, keyfile) -> ssl.SSLContext:
|
||||||
@ -34,13 +35,13 @@ def setup_logging(cfg: config.LogCfg):
|
|||||||
|
|
||||||
|
|
||||||
async def a_main(cfg: config.Config) -> None:
|
async def a_main(cfg: config.Config) -> None:
|
||||||
default_tls_context: ssl.SSLContext | None = None
|
default_tls_context: Optional[ssl.SSLContext] = None
|
||||||
|
|
||||||
if tls := cfg.default_tls:
|
if tls := cfg.default_tls:
|
||||||
logging.info(f"Initializing default tls {tls.certfile=}, {tls.keyfile=}")
|
logging.info(f"Initializing default tls {tls.certfile=}, {tls.keyfile=}")
|
||||||
default_tls_context = create_tls_context(tls.certfile, tls.keyfile)
|
default_tls_context = create_tls_context(tls.certfile, tls.keyfile)
|
||||||
|
|
||||||
def get_tls_context(tls: config.TLSCfg | str):
|
def get_tls_context(tls: Union[config.TLSCfg, str]):
|
||||||
if tls == "default":
|
if tls == "default":
|
||||||
return default_tls_context
|
return default_tls_context
|
||||||
elif tls == "disable":
|
elif tls == "disable":
|
||||||
|
@ -7,7 +7,7 @@ import uuid
|
|||||||
import shutil
|
import shutil
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable
|
from typing import Callable, Optional
|
||||||
from . import config
|
from . import config
|
||||||
from email.message import Message
|
from email.message import Message
|
||||||
import email.policy
|
import email.policy
|
||||||
@ -115,7 +115,7 @@ async def create_smtp_server(
|
|||||||
port: int,
|
port: int,
|
||||||
mails_path: Path,
|
mails_path: Path,
|
||||||
mbox_finder: Callable[[str], list[str]],
|
mbox_finder: Callable[[str], list[str]],
|
||||||
ssl_context: ssl.SSLContext | None = None,
|
ssl_context: Optional[ssl.SSLContext] = None,
|
||||||
) -> asyncio.Server:
|
) -> asyncio.Server:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Starting SMTP server {host=}, {port=}, {mails_path=!s}, {ssl_context != None=}"
|
f"Starting SMTP server {host=}, {port=}, {mails_path=!s}, {ssl_context != None=}"
|
||||||
|
Loading…
Reference in New Issue
Block a user