diff --git a/.config/dictionary.txt b/.config/dictionary.txt index 8a2014ec..a778e16e 100644 --- a/.config/dictionary.txt +++ b/.config/dictionary.txt @@ -1,3 +1,4 @@ +accesslog ADT Ansibuddy antsibull diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f08a4b13..a93e5b41 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -104,6 +104,7 @@ repos: - django-stubs[compatible-mypy] - jinja2 - pytest + - ansible-creator - tox - types-pyyaml - types-requests diff --git a/pyproject.toml b/pyproject.toml index 0d29eb87..45c92f83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ strict = true [[tool.mypy.overrides]] ignore_missing_imports = true -module = ["gunicorn.*", "openapi_core.*", "ansible_creator.*"] +module = ["gunicorn.*", "openapi_core.*"] [tool.pydoclint] allow-init-docstring = true diff --git a/src/ansible_dev_tools/resources/server/creator.py b/src/ansible_dev_tools/resources/server/creator.py index 5dadbbe4..11c10701 100644 --- a/src/ansible_dev_tools/resources/server/creator.py +++ b/src/ansible_dev_tools/resources/server/creator.py @@ -96,8 +96,7 @@ def collection( ) -# TO-DO: remove type ignore after creator is released with py.typed -class CreatorOutput(Output): # type: ignore[misc] +class CreatorOutput(Output): """The creator output.""" def __init__(self: CreatorOutput, log_file: str) -> None: diff --git a/src/ansible_dev_tools/subcommands/server.py b/src/ansible_dev_tools/subcommands/server.py index e6a33cc1..42414224 100644 --- a/src/ansible_dev_tools/subcommands/server.py +++ b/src/ansible_dev_tools/subcommands/server.py @@ -71,7 +71,6 @@ def __init__(self: Server, port: str, debug: bool) -> None: # noqa: FBT001 self.debug: bool = debug settings.configure( - DEBUG=self.debug, SECRET_KEY=os.environ.get("SECRET_KEY", os.urandom(32)), ALLOWED_HOSTS=[ "*", @@ -91,4 +90,8 @@ def run(self: Server) -> None: options = { "bind": f"0.0.0.0:{self.port}", } + if self.debug: + # set log level to debug and write access logs to stdout + options.update({"loglevel": "debug", "accesslog": "-"}) + AdtServerApp(self.application, options).run() diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 11b2ef88..039e582f 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -14,7 +14,9 @@ def dev_tools_server() -> Generator[str, None, None]: """Run the server.""" bin_path = Path(sys.executable).parent / "adt" - with subprocess.Popen([bin_path, "server", "-p", "8000"]) as proc: # noqa: S603 + with subprocess.Popen( + [bin_path, "server", "-p", "8000", "--debug"], # noqa: S603 + ) as proc: time.sleep(1) # allow the server to start yield "http://localhost:8000" proc.terminate()