Compare commits

..

2 Commits

5 changed files with 28 additions and 14 deletions

View File

@ -1,10 +1,10 @@
# Needs python3 >= 3.9, sed, git for build, docker for tests
build: clean
# Needs python3 >= 3.9, sed, git for build
mail4one.pyz: requirements.txt mail4one/*py
python3 -m pip install -r requirements.txt --no-compile --target build
cp -r mail4one/ build/
sed -i "s/DEVELOMENT/$(shell scripts/get_version.sh)/" build/mail4one/version.py
find build -name "*.pyi" -o -name "py.typed" | xargs -I typefile rm typefile
rm -rf build/bin
rm -rf build/bin build/aiosmtpd/{docs,tests,qa}
rm -rf build/mail4one/__pycache__
rm -rf build/*.dist-info
python3 -m zipapp \
@ -13,10 +13,19 @@ build: clean
--main mail4one.server:main \
--compress build
.PHONY: build
build: clean mail4one.pyz
.PHONY: test
test: mail4one.pyz
PYTHONPATH=mail4one.pyz python3 -m unittest discover
.PHONY: clean
clean:
rm -rf build
rm -rf mail4one.pyz
.PHONY: docker-tests
docker-tests:
docker run --pull=always -v `pwd`:/app -w /app --rm python:3.11-alpine sh scripts/runtests.sh
docker run --pull=always -v `pwd`:/app -w /app --rm python:3.10-alpine sh scripts/runtests.sh
@ -31,24 +40,31 @@ docker-tests:
requirements.txt: Pipfile.lock
pipenv requirements > requirements.txt
.PHONY: format
format:
black mail4one/*py tests/*py
.PHONY: build-dev
build-dev: requirements.txt build
.PHONY: setup
setup:
pipenv install
.PHONY: cleanup
cleanup:
pipenv --rm
.PHONY: update
update:
rm requirements.txt Pipfile.lock
pipenv update
pipenv requirements > requirements.txt
.PHONY: shell
shell:
MYPYPATH=`pipenv --venv`/lib/python3.11/site-packages pipenv shell
MYPYPATH=$(shell ls -d `pipenv --venv`/lib/python3*/site-packages) pipenv shell
test:
.PHONY: dev-test
dev-test:
pipenv run python -m unittest discover

View File

@ -1,4 +1,5 @@
import json
"""Module for parsing mail4one config.json"""
import re
import logging
from typing import Callable, Union, Optional

View File

@ -3,14 +3,14 @@ import contextlib
import contextvars
import logging
import ssl
import random
from typing import Optional
from asyncio import StreamReader, StreamWriter
from dataclasses import dataclass
from pathlib import Path
from .config import User
from .pwhash import parse_hash, check_pass, PWInfo
from asyncio import StreamReader, StreamWriter
import random
from typing import Optional
from .poputils import (
InvalidCommand,
@ -313,12 +313,10 @@ async def start_session() -> None:
assert state().mbox
await transaction_stage()
logger.info(f"User:{state().username} done")
except ClientDisconnected as c:
except ClientDisconnected:
logger.info("Client disconnected")
pass
except ClientQuit:
logger.info("Client QUIT")
pass
except ClientError as c:
write(err("Something went wrong"))
logger.error(f"Unexpected client error: {c}")

View File

@ -4,6 +4,7 @@ import ssl
from argparse import ArgumentParser
from pathlib import Path
from getpass import getpass
from typing import Optional, Union
from .smtp import create_smtp_server_starttls, create_smtp_server
from .pop3 import create_pop_server
@ -11,7 +12,6 @@ from .version import VERSION
from . import config
from . import pwhash
from typing import Optional, Union
def create_tls_context(certfile, keyfile) -> ssl.SSLContext:

View File

@ -6,7 +6,6 @@ import shutil
from functools import partial
from pathlib import Path
from typing import Callable, Optional
from . import config
from email.message import Message
import email.policy
from email.generator import BytesGenerator