make file improvements and some pylint cleanup
This commit is contained in:
parent
cb15ec15e4
commit
e853cfe62d
14
Makefile
14
Makefile
@ -1,10 +1,11 @@
|
|||||||
# Needs python3 >= 3.9, sed, git for build, docker for tests
|
# Needs python3 >= 3.9, sed, git for build, docker for tests
|
||||||
|
.PHONY: build
|
||||||
build: clean
|
build: clean
|
||||||
python3 -m pip install -r requirements.txt --no-compile --target build
|
python3 -m pip install -r requirements.txt --no-compile --target build
|
||||||
cp -r mail4one/ build/
|
cp -r mail4one/ build/
|
||||||
sed -i "s/DEVELOMENT/$(shell scripts/get_version.sh)/" build/mail4one/version.py
|
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
|
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/mail4one/__pycache__
|
||||||
rm -rf build/*.dist-info
|
rm -rf build/*.dist-info
|
||||||
python3 -m zipapp \
|
python3 -m zipapp \
|
||||||
@ -13,10 +14,12 @@ build: clean
|
|||||||
--main mail4one.server:main \
|
--main mail4one.server:main \
|
||||||
--compress build
|
--compress build
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
rm -rf mail4one.pyz
|
rm -rf mail4one.pyz
|
||||||
|
|
||||||
|
.PHONY: docker-tests
|
||||||
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.11-alpine sh scripts/runtests.sh
|
||||||
docker run --pull=always -v `pwd`:/app -w /app --rm python:3.10-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 +34,31 @@ docker-tests:
|
|||||||
requirements.txt: Pipfile.lock
|
requirements.txt: Pipfile.lock
|
||||||
pipenv requirements > requirements.txt
|
pipenv requirements > requirements.txt
|
||||||
|
|
||||||
|
.PHONY: format
|
||||||
format:
|
format:
|
||||||
black mail4one/*py tests/*py
|
black mail4one/*py tests/*py
|
||||||
|
|
||||||
|
.PHONY: build-dev
|
||||||
build-dev: requirements.txt build
|
build-dev: requirements.txt build
|
||||||
|
|
||||||
|
.PHONY: setup
|
||||||
setup:
|
setup:
|
||||||
pipenv install
|
pipenv install
|
||||||
|
|
||||||
|
.PHONY: cleanup
|
||||||
cleanup:
|
cleanup:
|
||||||
pipenv --rm
|
pipenv --rm
|
||||||
|
|
||||||
|
.PHONY: update
|
||||||
update:
|
update:
|
||||||
rm requirements.txt Pipfile.lock
|
rm requirements.txt Pipfile.lock
|
||||||
pipenv update
|
pipenv update
|
||||||
pipenv requirements > requirements.txt
|
pipenv requirements > requirements.txt
|
||||||
|
|
||||||
|
.PHONY: shell
|
||||||
shell:
|
shell:
|
||||||
MYPYPATH=`pipenv --venv`/lib/python3.11/site-packages pipenv shell
|
MYPYPATH=$(shell ls -d `pipenv --venv`/lib/python3*/site-packages) pipenv shell
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
pipenv run python -m unittest discover
|
pipenv run python -m unittest discover
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import json
|
"""Module for parsing mail4one config.json"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
from typing import Callable, Union, Optional
|
from typing import Callable, Union, Optional
|
||||||
|
@ -3,14 +3,14 @@ import contextlib
|
|||||||
import contextvars
|
import contextvars
|
||||||
import logging
|
import logging
|
||||||
import ssl
|
import ssl
|
||||||
|
import random
|
||||||
|
from typing import Optional
|
||||||
|
from asyncio import StreamReader, StreamWriter
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from .config import User
|
from .config import User
|
||||||
from .pwhash import parse_hash, check_pass, PWInfo
|
from .pwhash import parse_hash, check_pass, PWInfo
|
||||||
from asyncio import StreamReader, StreamWriter
|
|
||||||
import random
|
|
||||||
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from .poputils import (
|
from .poputils import (
|
||||||
InvalidCommand,
|
InvalidCommand,
|
||||||
@ -313,12 +313,10 @@ async def start_session() -> None:
|
|||||||
assert state().mbox
|
assert state().mbox
|
||||||
await transaction_stage()
|
await transaction_stage()
|
||||||
logger.info(f"User:{state().username} done")
|
logger.info(f"User:{state().username} done")
|
||||||
except ClientDisconnected as c:
|
except ClientDisconnected:
|
||||||
logger.info("Client disconnected")
|
logger.info("Client disconnected")
|
||||||
pass
|
|
||||||
except ClientQuit:
|
except ClientQuit:
|
||||||
logger.info("Client QUIT")
|
logger.info("Client QUIT")
|
||||||
pass
|
|
||||||
except ClientError as c:
|
except ClientError as c:
|
||||||
write(err("Something went wrong"))
|
write(err("Something went wrong"))
|
||||||
logger.error(f"Unexpected client error: {c}")
|
logger.error(f"Unexpected client error: {c}")
|
||||||
|
@ -4,6 +4,7 @@ import ssl
|
|||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
|
from typing import Optional, Union
|
||||||
|
|
||||||
from .smtp import create_smtp_server_starttls, create_smtp_server
|
from .smtp import create_smtp_server_starttls, create_smtp_server
|
||||||
from .pop3 import create_pop_server
|
from .pop3 import create_pop_server
|
||||||
@ -11,7 +12,6 @@ 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:
|
||||||
|
@ -6,7 +6,6 @@ import shutil
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
from . import config
|
|
||||||
from email.message import Message
|
from email.message import Message
|
||||||
import email.policy
|
import email.policy
|
||||||
from email.generator import BytesGenerator
|
from email.generator import BytesGenerator
|
||||||
|
Loading…
Reference in New Issue
Block a user