From 45a9d202044460182bf6a27112c35af326feca8d Mon Sep 17 00:00:00 2001 From: Minion3665 Date: Mon, 15 Aug 2022 23:06:15 +0000 Subject: [PATCH] Automated push for workflow: [Lint/#&] --- app/__init__.py | 20 ++++++++++---------- app/config.py | 2 +- app/main.py | 4 +++- app/routers.py | 1 - app/runner.py | 3 ++- test/test_runner.py | 3 +++ 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 9a8b033..4f743ab 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -3,15 +3,15 @@ from app.main import app pretty_errors.configure( - separator_character = '*', - filename_display = pretty_errors.FILENAME_EXTENDED, - line_number_first = True, - display_link = True, - lines_before = 5, - lines_after = 2, - line_color = pretty_errors.RED + '> ' + pretty_errors.default_config.line_color, - code_color = ' ' + pretty_errors.default_config.line_color, - truncate_code = True, - display_locals = True + separator_character='*', + filename_display=pretty_errors.FILENAME_EXTENDED, + line_number_first=True, + display_link=True, + lines_before=5, + lines_after=2, + line_color=pretty_errors.RED + '> ' + pretty_errors.default_config.line_color, + code_color=' ' + pretty_errors.default_config.line_color, + truncate_code=True, + display_locals=True ) pretty_errors.blacklist('c:/python') diff --git a/app/config.py b/app/config.py index 0e7db94..7ccf28d 100644 --- a/app/config.py +++ b/app/config.py @@ -3,6 +3,7 @@ from pydantic import BaseSettings from pathlib import Path + class Settings(BaseSettings): output_file_path: Path = Path("logs.txt") @@ -25,4 +26,3 @@ class Settings(BaseSettings): config = Settings() if config.on_brain is True: config.robot_env["PYTHONPATH"] = config.robot_path - diff --git a/app/main.py b/app/main.py index d3ea7d6..f8420a3 100644 --- a/app/main.py +++ b/app/main.py @@ -14,10 +14,12 @@ app.include_router(routers.runner_router) app.include_router(routers.upload_router) + @app.get("/") def root(): return "Root of shepherd-2" + @app.on_event("shutdown") def shutdown_event(): """Make sure that we kill any running usercode @@ -27,4 +29,4 @@ def shutdown_event(): if __name__ == '__main__': - uvicorn.run(app, port=8080, host='0.0.0.0') \ No newline at end of file + uvicorn.run(app, port=8080, host='0.0.0.0') diff --git a/app/routers.py b/app/routers.py index 8909d0a..16baa85 100644 --- a/app/routers.py +++ b/app/routers.py @@ -52,4 +52,3 @@ def upload_file(file: UploadFile): "filename": file.filename, "filesize": len(file) } - diff --git a/app/runner.py b/app/runner.py index 75d02d0..ceb94dd 100644 --- a/app/runner.py +++ b/app/runner.py @@ -53,7 +53,7 @@ def _enter_ready_state(self) -> None: def _enter_running_state(self) -> None: """Send start signal to usercode""" - pass # TODO: + pass # TODO: def _enter_stopped_state(self) -> None: """Reap the users code""" @@ -135,4 +135,5 @@ def _run_watchdog(self) -> None: self.next_state = States.STOPPED self.new_state_event.set() + runner = Runner() diff --git a/test/test_runner.py b/test/test_runner.py index 0e854c5..93ea5db 100644 --- a/test/test_runner.py +++ b/test/test_runner.py @@ -7,6 +7,7 @@ client = TestClient(app) + @pytest.mark.timeout(STATE_TRANS_TIMEOUT) def test_inital_state(): """The server is ready to run code within STATE_TRANS_TIMEOUT seconds of starting""" @@ -14,6 +15,7 @@ def test_inital_state(): pass assert response.status_code == 200 + @pytest.mark.timeout(STATE_TRANS_TIMEOUT) def test_start(): """Code can be started""" @@ -22,6 +24,7 @@ def test_start(): pass assert response.status_code == 200 + @pytest.mark.timeout(STATE_TRANS_TIMEOUT) def test_stop(): """Code can be stopped within STATE_TRANS_TIMEOUT seconds of it commanding to be stopped"""