From 285999225bc71807b60865c5565f4e507b733fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Thu, 3 Mar 2022 23:35:45 +0100 Subject: [PATCH] feat: setup code-workspace --- .vscode/launch.json | 26 +++---------- .vscode/settings.json | 4 +- .vscode/tasks.json | 58 +++++++++++++++++++++++++---- src/emulator/.vscode/launch.json | 13 +++++++ src/emulator/.vscode/setttings.json | 14 +++++++ src/emulator/env.py | 4 +- src/emulator/pyproject.toml | 2 +- src/mgba | 1 + src/server/.vscode/launch.json | 13 +++++++ src/server/.vscode/setttings.json | 14 +++++++ workspace.code-workspace | 13 +++++++ 11 files changed, 127 insertions(+), 35 deletions(-) create mode 100644 src/emulator/.vscode/launch.json create mode 100644 src/emulator/.vscode/setttings.json create mode 160000 src/mgba create mode 100644 src/server/.vscode/launch.json create mode 100644 src/server/.vscode/setttings.json create mode 100644 workspace.code-workspace diff --git a/.vscode/launch.json b/.vscode/launch.json index 0d1f6d4..c618c0c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,30 +1,14 @@ { "version": "0.2.0", - "configurations": [ - { - "name": "Server", - "type": "python", - "request": "launch", - "program": "${workspaceFolder}/src/server.py", - "console": "integratedTerminal", - "envFile": "" - }, - { - "name": "Emulator", - "type": "python", - "request": "launch", - "program": "${workspaceFolder}/src/emulator.py", - "console": "integratedTerminal", - "envFile": "" - } - ], "compounds": [ { - "name": "Server/Emulator", + "name": "Launch", "configurations": [ - "Server", - "Emulator" + "Launch (server)", + "Launch (emulator)" ], + "preLaunchTask": "Start NGINX+Redis", + // "postLaunchask": "Stop NGINX+Redis", // not yet supported by vscode, launch the task manually "stopAll": true } ] diff --git a/.vscode/settings.json b/.vscode/settings.json index decc370..1fbf8cf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,4 @@ { - // "python.defaultInterpreterPath": "${workspaceFolder}/src/server/.venv/bin/python", "python.formatting.provider": "black", "editor.formatOnSave": true, "python.linting.enabled": true, @@ -13,7 +12,6 @@ } }, "python.analysis.extraPaths": [ - "${workspaceFolder}/mgba/src/platform/python", - "./src/mgba/src/platform/python" + "${workspaceFolder}/src/mgba/src/platform/python", ], } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 86054e0..40941ef 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,14 +2,56 @@ "version": "2.0.0", "tasks": [ { - "label": "Redis server", - "command": "redis-server", - "type": "process", - "isBackground": true, - "problemMatcher": [], - "presentation": { - "reveal": "silent" - }, + "label": "Start NGINX", + "type": "docker-run", + "dockerRun": { + "containerName": "nginx-rtmp", + "image": "tiangolo/nginx-rtmp", + "ports": [ + { + "containerPort": 1935, + "hostPort": 1935 + } + ], + "remove": true + } + }, + { + "label": "Start Redis", + "type": "docker-run", + "dockerRun": { + "containerName": "redis", + "image": "redis:alpine", + "ports": [ + { + "containerPort": 6379, + "hostPort": 6379 + } + ], + "remove": true + } + }, + { + "label": "Start NGINX+Redis", + "dependsOn": [ + "Start NGINX", + "Start Redis" + ] + }, + { + "label": "Stop NGINX", + "type": "shell", + "command": "docker stop nginx-rtmp" + }, + { + "label": "Stop NGINX", + "type": "shell", + "command": "docker stop redis" + }, + { + "label": "Stop NGINX+Redis", + "type": "shell", + "command": "docker stop redis nginx-rtmp" } ] } diff --git a/src/emulator/.vscode/launch.json b/src/emulator/.vscode/launch.json new file mode 100644 index 0000000..a04013f --- /dev/null +++ b/src/emulator/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch (emulator)", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/main.py", + "console": "integratedTerminal", + "envFile": "" + } + ] +} diff --git a/src/emulator/.vscode/setttings.json b/src/emulator/.vscode/setttings.json new file mode 100644 index 0000000..86222c9 --- /dev/null +++ b/src/emulator/.vscode/setttings.json @@ -0,0 +1,14 @@ +{ + "python.formatting.provider": "black", + "editor.formatOnSave": true, + "python.linting.enabled": true, + "python.linting.lintOnSave": true, + "python.linting.flake8Enabled": true, + "python.linting.mypyEnabled": true, + "python.linting.banditEnabled": true, + "[python]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + } +} diff --git a/src/emulator/env.py b/src/emulator/env.py index d0e4bd8..770a881 100644 --- a/src/emulator/env.py +++ b/src/emulator/env.py @@ -16,8 +16,8 @@ EMULATOR_FPS: int = int(getenv("EMULATOR_FPS", 60)) EMULATOR_SPF: float = 1.0 / EMULATOR_FPS EMULATOR_INPUT_HZ: int = int(getenv("EMULATOR_INPUT_HZ", 10)) EMULATOR_POLLING_RATE: int = EMULATOR_FPS // EMULATOR_INPUT_HZ -EMULATOR_ROM_PATH: str = getenv("EMULATOR_ROM_PATH", "roms/pokemon.gba") -EMULATOR_STATES_PATH: str = getenv("EMULATOR_STATES_PATH", "states/") +EMULATOR_ROM_PATH: str = getenv("EMULATOR_ROM_PATH", "../../roms/pokemon.gba") +EMULATOR_STATES_PATH: str = getenv("EMULATOR_STATES_PATH", "../../states/") EMULATOR_RAND_RATE: float = float(getenv("EMULATOR_RAND_RATE", 0.0)) FFMPEG_WIDTH: int = int(getenv("FFMPEG_WIDTH", EMULATOR_WIDTH)) diff --git a/src/emulator/pyproject.toml b/src/emulator/pyproject.toml index 924c55d..ed1214c 100644 --- a/src/emulator/pyproject.toml +++ b/src/emulator/pyproject.toml @@ -12,7 +12,6 @@ cffi = "^1.15.0" cached-property = "^1.5.2" Pillow = "^8.4.0" redis = "^3.5.3" -mgba = { path="../mgba/src/platform/python" } watchdog = "^2.1.6" [tool.poetry.dev-dependencies] @@ -24,6 +23,7 @@ bandit = "^1.7.0" isort = "^5.9.3" mypy = "^0.931" types-redis = "^3.5.15" +mgba = { path="../mgba/src/platform/python" } [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/src/mgba b/src/mgba new file mode 160000 index 0000000..0676769 --- /dev/null +++ b/src/mgba @@ -0,0 +1 @@ +Subproject commit 0676769b6897408fa009c8a6cb29f1824fd4f6e7 diff --git a/src/server/.vscode/launch.json b/src/server/.vscode/launch.json new file mode 100644 index 0000000..02f3cd5 --- /dev/null +++ b/src/server/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch (server)", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/main.py", + "console": "integratedTerminal", + "envFile": "" + } + ] +} diff --git a/src/server/.vscode/setttings.json b/src/server/.vscode/setttings.json new file mode 100644 index 0000000..86222c9 --- /dev/null +++ b/src/server/.vscode/setttings.json @@ -0,0 +1,14 @@ +{ + "python.formatting.provider": "black", + "editor.formatOnSave": true, + "python.linting.enabled": true, + "python.linting.lintOnSave": true, + "python.linting.flake8Enabled": true, + "python.linting.mypyEnabled": true, + "python.linting.banditEnabled": true, + "[python]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + } +} diff --git a/workspace.code-workspace b/workspace.code-workspace new file mode 100644 index 0000000..2015733 --- /dev/null +++ b/workspace.code-workspace @@ -0,0 +1,13 @@ +{ + "folders": [ + { + "path": "src/emulator" + }, + { + "path": "src/server" + }, + { + "path": "." + } + ] +}