diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 0cee4d445..4e14fb364 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -7,39 +7,30 @@ on: env: MCO_LOG_LEVEL: warn EXTERNAL_HOST: mcouniverse.com - PRIVATE_KEY_FILE: thebeast/data/private_key.pem - CERTIFICATE_FILE: thebeast/data/mcouniverse.crt - PUBLIC_KEY_FILE: thebeast/data/pub.key + PRIVATE_KEY_FILE: thebeast/data/private_key.pem # These secrets are stored in the repository and are safe to "leak" + CERTIFICATE_FILE: thebeast/data/mcouniverse.crt # These secrets are stored in the repository and are safe to "leak" + PUBLIC_KEY_FILE: thebeast/data/pub.key # These secrets are stored in the repository and are safe to "leak" jobs: build-test: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x, 21.x] - steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 with: fetch-depth: 0 - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js 22.x uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 with: - node-version: ${{ matrix.node-version }} - # - name: Resolve Outdated Comments - # uses: Ardiannn08/resolve-outdated-comment@v1.3 - # with: - # token: ${{ secrets.GH_TOKEN }} - # mode: "delete" + node-version: 22.x - name: Install and test run: | npm install - npm run test --workspaces --if-present + npm test env: CODECOV_UPLOAD_BUNDLE_TOKEN: ${{ secrets.CODECOV_UPLOAD_BUNDLE_TOKEN }} - name: Codecov - if: ${{ always() }} + if: ${{ always() }} # using always() to always run this step because i am uploading test results and coverage in one step env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} run: | diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml deleted file mode 100644 index 3795e5a17..000000000 --- a/.github/workflows/python.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Python - -on: - push: - pull_request: - -permissions: - contents: read - -jobs: - Testing: - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ['3.12'] - os: [ubuntu-latest, macOS-latest] - - steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - - name: Set up PDM - uses: pdm-project/setup-pdm@568ddd69406b30de1774ec0044b73ae06e716aa4 # v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - pdm sync -d -G test - - name: Run Tests - uses: coactions/setup-xvfb@b6b4fcfb9f5a895edadc3bc76318fae0ac17c8b3 # v1 - with: - run: pdm test diff --git a/.pdm-python b/.pdm-python deleted file mode 100644 index ac12215f5..000000000 --- a/.pdm-python +++ /dev/null @@ -1 +0,0 @@ -/home/drazisil/mcos/.venv/bin/python diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 492e008c6..000000000 --- a/Pipfile +++ /dev/null @@ -1,37 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -black = "==24.4.2" -cfgv = "==3.4.0" -click = "==8.1.7" -colorama = "==0.4.6" -coverage = "==7.5.4" -distlib = "==0.3.8" -filelock = "==3.15.4" -flake8 = "==7.1.0" -flake8-black = "==0.3.6" -identify = "==2.5.36" -iniconfig = "==2.0.0" -mccabe = "==0.7.0" -mypy-extensions = "==1.0.0" -nodeenv = "==1.9.1" -packaging = "==24.1" -pathspec = "==0.12.1" -platformdirs = "==4.2.2" -pluggy = "==1.5.0" -pre-commit = "==3.7.1" -pycodestyle = "==2.12.0" -pyflakes = "==3.2.0" -pytest = "==8.2.2" -pyyaml = "==6.0.1" -serializable = {file = "libs/serializable", editable = true} -server = {file = "projects/server", editable = true} -virtualenv = "==20.26.3" - -[dev-packages] - -[requires] -python_version = "3.12" diff --git a/STARTING.md b/STARTING.md index b1998e463..b524cc54d 100644 --- a/STARTING.md +++ b/STARTING.md @@ -2,11 +2,11 @@ Documention type: Tutorial -Last updated: 2003c90b4aecc5150116e83a0f14d18f44bf3536 +Last updated: 40f6623947ee7a5c2ab90f9b1f64331c40180514 --- -This project isn't really geared towards an player of the game, but if you want to try it out, this is how to do so: +This project isn't really geared towards a player of the game, but if you want to try it out, this is how to do so: ## Requirements @@ -17,7 +17,8 @@ This project isn't really geared towards an player of the game, but if you want - Git - Docker - Docker Compose -- NodeJS (v20.x - v21.x) +- NodeJS (v22.x) +- NVM - The debug copy of the game ## Setup @@ -31,9 +32,9 @@ After getting the requirements above ready, perform the following steps: 3. Type `cd rusty-server` and press enter 4. Type `./mcos/pull_nginx_image.sh` and press enter (this step may take a while, depending on your internet speed) 5. Type `docker-compose up -d` and press enter -6. Type `corepack enable pnpm` and press enter -7. Type `pnpm install` and press enter -8. Type `pnpm run build` and press enter +6. Type `nvm install && nvm use` and press enter +7. Type `npm install` and press enter +8. Type `npm run build` and press enter 9. Type `cp .env.example .env` and press enter 10. Open the `.env` file with your favorite text editing program (the simpler the better) and edit the values as follows: a. `EXTERNAL_HOST=` - Add the hostname or ip of the computer you are running this server on. This value MUST be reachable from where you install the game. @@ -61,7 +62,7 @@ After getting the requirements above ready, perform the following steps: 9. Click "Next" 10. You are now on a screen that asks where you want to save this certificate. 11. Click on the "Place all certificates in the following store" and click "browse" -12. Select "Trusted Roor Certification Authorities". This should be the second one down. +12. Select "Trusted Root Certification Authorities". This should be the second one down. 13. Click "Ok" 14. Click "Next" 15. Click "Finish" @@ -96,6 +97,5 @@ After getting the requirements above ready, perform the following steps: If you haven't followed all the steps under the Setup section, this will probably not work well 37. Double-click the debug copy of the game -38. There are two pre-created logins, depending on what part you to see: - a. Username: "admin", Password: "admin" - No existing account, profile creation possible (not playabl, even if it says it was created) - b. Username: "molly", Password: "molly" - Existing account, can login to the server and reach the lobby. Any activities past that probably won't work. +38. These are the possible pre-created logins + a. Username: "admin", Password: "admin" - No existing profile, profile design possible, but no cars to buy so you can't create diff --git a/libs/serializable/.gitignore b/libs/serializable/.gitignore deleted file mode 100644 index 3a8816c9e..000000000 --- a/libs/serializable/.gitignore +++ /dev/null @@ -1,162 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm-project.org/#use-with-ide -.pdm.toml -.pdm-python -.pdm-build/ - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ diff --git a/libs/serializable/README.md b/libs/serializable/README.md deleted file mode 100644 index 7e5b8c84f..000000000 --- a/libs/serializable/README.md +++ /dev/null @@ -1 +0,0 @@ -# serializable diff --git a/libs/serializable/pyproject.toml b/libs/serializable/pyproject.toml deleted file mode 100644 index a946e7312..000000000 --- a/libs/serializable/pyproject.toml +++ /dev/null @@ -1,15 +0,0 @@ -[project] -name = "serializable" -version = "0.1.0" -description = "Default template for PDM package" -authors = [ - {name = "Molly Draven", email = "drazi@duck.com"}, -] -dependencies = [] -requires-python = "==3.12.*" -readme = "README.md" -license = {text = "AGPL-3.0"} - - -[tool.pdm] -distribution = false diff --git a/libs/serializable/src/serializable/__init__.py b/libs/serializable/src/serializable/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/serializable/tests/__init__.py b/libs/serializable/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/nx.json b/nx.json deleted file mode 100644 index 9b9a33566..000000000 --- a/nx.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "./node_modules/nx/schemas/nx-schema.json", - "targetDefaults": { - "check": { - "cache": true - }, - "lint": { - "cache": true - }, - "format": { - "cache": true - }, - "test": { - "cache": true - } - }, - "defaultBase": "main", - "nxCloudAccessToken": "MWE5ZDAyNTQtM2JiNC00ZmIyLWI5MDEtYzFkYjhiMzgwMGMyfHJlYWQtd3JpdGU=" -} diff --git a/package.json b/package.json index ffebab869..12253e2de 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "scripts": { "clean": "rm -rf **/node_modules", "start": "node --openssl-legacy-provider --env-file=.env --loader ts-node/esm ./apps/main/server.ts", + "test": "npm run test:all", "test:all": "npm run test --workspaces --if-present" }, "type": "module", @@ -33,8 +34,5 @@ "packages/shared", "packages/shared-packets", "schema" - ], - "devDependencies": { - "nx": "19.4.1" - } + ] } diff --git a/pdm.lock b/pdm.lock deleted file mode 100644 index 722ca2536..000000000 --- a/pdm.lock +++ /dev/null @@ -1,394 +0,0 @@ -# This file is @generated by PDM. -# It is not intended for manual editing. - -[metadata] -groups = ["default", "dev", "test"] -strategy = ["cross_platform", "inherit_metadata"] -lock_version = "4.4.1" -content_hash = "sha256:89838dee197c16cfdd85bde8e4896ea98cbd4427df9b2683ce91ec8527a4004b" - -[[package]] -name = "black" -version = "24.4.2" -requires_python = ">=3.8" -summary = "The uncompromising code formatter." -groups = ["dev"] -dependencies = [ - "click>=8.0.0", - "mypy-extensions>=0.4.3", - "packaging>=22.0", - "pathspec>=0.9.0", - "platformdirs>=2", -] -files = [ - {file = "black-24.4.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:accf49e151c8ed2c0cdc528691838afd217c50412534e876a19270fea1e28e2d"}, - {file = "black-24.4.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:88c57dc656038f1ab9f92b3eb5335ee9b021412feaa46330d5eba4e51fe49b04"}, - {file = "black-24.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be8bef99eb46d5021bf053114442914baeb3649a89dc5f3a555c88737e5e98fc"}, - {file = "black-24.4.2-cp312-cp312-win_amd64.whl", hash = "sha256:415e686e87dbbe6f4cd5ef0fbf764af7b89f9057b97c908742b6008cc554b9c0"}, - {file = "black-24.4.2-py3-none-any.whl", hash = "sha256:d36ed1124bb81b32f8614555b34cc4259c3fbc7eec17870e8ff8ded335b58d8c"}, - {file = "black-24.4.2.tar.gz", hash = "sha256:c872b53057f000085da66a19c55d68f6f8ddcac2642392ad3a355878406fbd4d"}, -] - -[[package]] -name = "certifi" -version = "2024.6.2" -requires_python = ">=3.6" -summary = "Python package for providing Mozilla's CA Bundle." -groups = ["default"] -files = [ - {file = "certifi-2024.6.2-py3-none-any.whl", hash = "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56"}, - {file = "certifi-2024.6.2.tar.gz", hash = "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516"}, -] - -[[package]] -name = "cfgv" -version = "3.4.0" -requires_python = ">=3.8" -summary = "Validate configuration and produce human readable error messages." -groups = ["dev"] -files = [ - {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, - {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, -] - -[[package]] -name = "click" -version = "8.1.7" -requires_python = ">=3.7" -summary = "Composable command line interface toolkit" -groups = ["dev"] -dependencies = [ - "colorama; platform_system == \"Windows\"", -] -files = [ - {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, - {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, -] - -[[package]] -name = "colorama" -version = "0.4.6" -requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -summary = "Cross-platform colored terminal text." -groups = ["dev", "test"] -marker = "sys_platform == \"win32\" or platform_system == \"Windows\"" -files = [ - {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, - {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, -] - -[[package]] -name = "coverage" -version = "7.5.3" -requires_python = ">=3.8" -summary = "Code coverage measurement for Python" -groups = ["test"] -files = [ - {file = "coverage-7.5.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:296a7d9bbc598e8744c00f7a6cecf1da9b30ae9ad51c566291ff1314e6cbbed8"}, - {file = "coverage-7.5.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:34d6d21d8795a97b14d503dcaf74226ae51eb1f2bd41015d3ef332a24d0a17b3"}, - {file = "coverage-7.5.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e317953bb4c074c06c798a11dbdd2cf9979dbcaa8ccc0fa4701d80042d4ebf1"}, - {file = "coverage-7.5.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:705f3d7c2b098c40f5b81790a5fedb274113373d4d1a69e65f8b68b0cc26f6db"}, - {file = "coverage-7.5.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b1196e13c45e327d6cd0b6e471530a1882f1017eb83c6229fc613cd1a11b53cd"}, - {file = "coverage-7.5.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:015eddc5ccd5364dcb902eaecf9515636806fa1e0d5bef5769d06d0f31b54523"}, - {file = "coverage-7.5.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:fd27d8b49e574e50caa65196d908f80e4dff64d7e592d0c59788b45aad7e8b35"}, - {file = "coverage-7.5.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:33fc65740267222fc02975c061eb7167185fef4cc8f2770267ee8bf7d6a42f84"}, - {file = "coverage-7.5.3-cp312-cp312-win32.whl", hash = "sha256:7b2a19e13dfb5c8e145c7a6ea959485ee8e2204699903c88c7d25283584bfc08"}, - {file = "coverage-7.5.3-cp312-cp312-win_amd64.whl", hash = "sha256:0bbddc54bbacfc09b3edaec644d4ac90c08ee8ed4844b0f86227dcda2d428fcb"}, - {file = "coverage-7.5.3-pp38.pp39.pp310-none-any.whl", hash = "sha256:3538d8fb1ee9bdd2e2692b3b18c22bb1c19ffbefd06880f5ac496e42d7bb3884"}, - {file = "coverage-7.5.3.tar.gz", hash = "sha256:04aefca5190d1dc7a53a4c1a5a7f8568811306d7a8ee231c42fb69215571944f"}, -] - -[[package]] -name = "distlib" -version = "0.3.8" -summary = "Distribution utilities" -groups = ["dev"] -files = [ - {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, - {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, -] - -[[package]] -name = "filelock" -version = "3.15.3" -requires_python = ">=3.8" -summary = "A platform independent file lock." -groups = ["dev"] -files = [ - {file = "filelock-3.15.3-py3-none-any.whl", hash = "sha256:0151273e5b5d6cf753a61ec83b3a9b7d8821c39ae9af9d7ecf2f9e2f17404103"}, - {file = "filelock-3.15.3.tar.gz", hash = "sha256:e1199bf5194a2277273dacd50269f0d87d0682088a3c561c15674ea9005d8635"}, -] - -[[package]] -name = "flake8" -version = "7.1.0" -requires_python = ">=3.8.1" -summary = "the modular source code checker: pep8 pyflakes and co" -groups = ["dev"] -dependencies = [ - "mccabe<0.8.0,>=0.7.0", - "pycodestyle<2.13.0,>=2.12.0", - "pyflakes<3.3.0,>=3.2.0", -] -files = [ - {file = "flake8-7.1.0-py2.py3-none-any.whl", hash = "sha256:2e416edcc62471a64cea09353f4e7bdba32aeb079b6e360554c659a122b1bc6a"}, - {file = "flake8-7.1.0.tar.gz", hash = "sha256:48a07b626b55236e0fb4784ee69a465fbf59d79eec1f5b4785c3d3bc57d17aa5"}, -] - -[[package]] -name = "flake8-black" -version = "0.3.6" -requires_python = ">=3.7" -summary = "flake8 plugin to call black as a code style validator" -groups = ["dev"] -dependencies = [ - "black>=22.1.0", - "flake8>=3", -] -files = [ - {file = "flake8-black-0.3.6.tar.gz", hash = "sha256:0dfbca3274777792a5bcb2af887a4cad72c72d0e86c94e08e3a3de151bb41c34"}, - {file = "flake8_black-0.3.6-py3-none-any.whl", hash = "sha256:fe8ea2eca98d8a504f22040d9117347f6b367458366952862ac3586e7d4eeaca"}, -] - -[[package]] -name = "identify" -version = "2.5.36" -requires_python = ">=3.8" -summary = "File identification library for Python" -groups = ["dev"] -files = [ - {file = "identify-2.5.36-py2.py3-none-any.whl", hash = "sha256:37d93f380f4de590500d9dba7db359d0d3da95ffe7f9de1753faa159e71e7dfa"}, - {file = "identify-2.5.36.tar.gz", hash = "sha256:e5e00f54165f9047fbebeb4a560f9acfb8af4c88232be60a488e9b68d122745d"}, -] - -[[package]] -name = "iniconfig" -version = "2.0.0" -requires_python = ">=3.7" -summary = "brain-dead simple config-ini parsing" -groups = ["test"] -files = [ - {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, - {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, -] - -[[package]] -name = "mccabe" -version = "0.7.0" -requires_python = ">=3.6" -summary = "McCabe checker, plugin for flake8" -groups = ["dev"] -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - -[[package]] -name = "mypy-extensions" -version = "1.0.0" -requires_python = ">=3.5" -summary = "Type system extensions for programs checked with the mypy type checker." -groups = ["dev"] -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - -[[package]] -name = "nodeenv" -version = "1.9.1" -requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -summary = "Node.js virtual environment builder" -groups = ["dev"] -files = [ - {file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"}, - {file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"}, -] - -[[package]] -name = "packaging" -version = "24.1" -requires_python = ">=3.8" -summary = "Core utilities for Python packages" -groups = ["dev", "test"] -files = [ - {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, - {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, -] - -[[package]] -name = "pathspec" -version = "0.12.1" -requires_python = ">=3.8" -summary = "Utility library for gitignore style pattern matching of file paths." -groups = ["dev"] -files = [ - {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, - {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, -] - -[[package]] -name = "platformdirs" -version = "4.2.2" -requires_python = ">=3.8" -summary = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." -groups = ["dev"] -files = [ - {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, - {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, -] - -[[package]] -name = "pluggy" -version = "1.5.0" -requires_python = ">=3.8" -summary = "plugin and hook calling mechanisms for python" -groups = ["test"] -files = [ - {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, - {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, -] - -[[package]] -name = "pre-commit" -version = "3.7.1" -requires_python = ">=3.9" -summary = "A framework for managing and maintaining multi-language pre-commit hooks." -groups = ["dev"] -dependencies = [ - "cfgv>=2.0.0", - "identify>=1.0.0", - "nodeenv>=0.11.1", - "pyyaml>=5.1", - "virtualenv>=20.10.0", -] -files = [ - {file = "pre_commit-3.7.1-py2.py3-none-any.whl", hash = "sha256:fae36fd1d7ad7d6a5a1c0b0d5adb2ed1a3bda5a21bf6c3e5372073d7a11cd4c5"}, - {file = "pre_commit-3.7.1.tar.gz", hash = "sha256:8ca3ad567bc78a4972a3f1a477e94a79d4597e8140a6e0b651c5e33899c3654a"}, -] - -[[package]] -name = "pycodestyle" -version = "2.12.0" -requires_python = ">=3.8" -summary = "Python style guide checker" -groups = ["dev"] -files = [ - {file = "pycodestyle-2.12.0-py2.py3-none-any.whl", hash = "sha256:949a39f6b86c3e1515ba1787c2022131d165a8ad271b11370a8819aa070269e4"}, - {file = "pycodestyle-2.12.0.tar.gz", hash = "sha256:442f950141b4f43df752dd303511ffded3a04c2b6fb7f65980574f0c31e6e79c"}, -] - -[[package]] -name = "pyflakes" -version = "3.2.0" -requires_python = ">=3.8" -summary = "passive checker of Python programs" -groups = ["dev"] -files = [ - {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, - {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, -] - -[[package]] -name = "pytest" -version = "8.2.2" -requires_python = ">=3.8" -summary = "pytest: simple powerful testing with Python" -groups = ["test"] -dependencies = [ - "colorama; sys_platform == \"win32\"", - "iniconfig", - "packaging", - "pluggy<2.0,>=1.5", -] -files = [ - {file = "pytest-8.2.2-py3-none-any.whl", hash = "sha256:c434598117762e2bd304e526244f67bf66bbd7b5d6cf22138be51ff661980343"}, - {file = "pytest-8.2.2.tar.gz", hash = "sha256:de4bb8104e201939ccdc688b27a89a7be2079b22e2bd2b07f806b6ba71117977"}, -] - -[[package]] -name = "pyyaml" -version = "6.0.1" -requires_python = ">=3.6" -summary = "YAML parser and emitter for Python" -groups = ["dev"] -files = [ - {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, - {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, - {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, - {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, - {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, -] - -[[package]] -name = "sentry-sdk" -version = "2.7.1" -requires_python = ">=3.6" -summary = "Python client for Sentry (https://sentry.io)" -groups = ["default"] -dependencies = [ - "certifi", - "urllib3>=1.26.11", -] -files = [ - {file = "sentry_sdk-2.7.1-py2.py3-none-any.whl", hash = "sha256:ef1b3d54eb715825657cd4bb3cb42bb4dc85087bac14c56b0fd8c21abd968c9a"}, - {file = "sentry_sdk-2.7.1.tar.gz", hash = "sha256:25006c7e68b75aaa5e6b9c6a420ece22e8d7daec4b7a906ffd3a8607b67c037b"}, -] - -[[package]] -name = "serializable" -version = "0.1.0" -requires_python = "==3.12.*" -editable = true -path = "./libs/serializable" -summary = "Default template for PDM package" -groups = ["dev"] - -[[package]] -name = "server" -version = "0.1.0" -requires_python = "==3.12.*" -editable = true -path = "./projects/server" -summary = "Default template for PDM package" -groups = ["default", "dev"] - -[[package]] -name = "tcl" -version = "0.2" -summary = "A coding language used for Graphical user interface" -groups = ["default"] -files = [ - {file = "Tcl-0.2-py3-none-any.whl", hash = "sha256:482e8147ed4c07563a621ffa5be874574527a9d60f5c3e9917b1f4079c5b27e5"}, - {file = "Tcl-0.2.tar.gz", hash = "sha256:395f69c382dedf29f88b6cce9114024528fce7f073d7b84eaefa9b608f3ea193"}, -] - -[[package]] -name = "urllib3" -version = "2.2.2" -requires_python = ">=3.8" -summary = "HTTP library with thread-safe connection pooling, file post, and more." -groups = ["default"] -files = [ - {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, - {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, -] - -[[package]] -name = "virtualenv" -version = "20.26.3" -requires_python = ">=3.7" -summary = "Virtual Python Environment builder" -groups = ["dev"] -dependencies = [ - "distlib<1,>=0.3.7", - "filelock<4,>=3.12.2", - "platformdirs<5,>=3.9.1", -] -files = [ - {file = "virtualenv-20.26.3-py3-none-any.whl", hash = "sha256:8cc4a31139e796e9a7de2cd5cf2489de1217193116a8fd42328f1bd65f434589"}, - {file = "virtualenv-20.26.3.tar.gz", hash = "sha256:4c43a2a236279d9ea36a0d76f98d84bd6ca94ac4e0f4a3b9d46d05e10fea542a"}, -] diff --git a/projects/server/.gitignore b/projects/server/.gitignore deleted file mode 100644 index 3a8816c9e..000000000 --- a/projects/server/.gitignore +++ /dev/null @@ -1,162 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm-project.org/#use-with-ide -.pdm.toml -.pdm-python -.pdm-build/ - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ diff --git a/projects/server/README.md b/projects/server/README.md deleted file mode 100644 index 00db566dc..000000000 --- a/projects/server/README.md +++ /dev/null @@ -1 +0,0 @@ -# server diff --git a/projects/server/pyproject.toml b/projects/server/pyproject.toml deleted file mode 100644 index 46fedae8b..000000000 --- a/projects/server/pyproject.toml +++ /dev/null @@ -1,15 +0,0 @@ -[project] -name = "server" -version = "0.1.0" -description = "Default template for PDM package" -authors = [ - {name = "Molly Draven", email = "drazi@duck.com"}, -] -dependencies = [] -requires-python = "==3.12.*" -readme = "README.md" -license = {text = "AGPL-3.0"} - - -[tool.pdm] -distribution = false diff --git a/projects/server/src/server/TCPRequestHandler.py b/projects/server/src/server/TCPRequestHandler.py deleted file mode 100644 index 9179087b7..000000000 --- a/projects/server/src/server/TCPRequestHandler.py +++ /dev/null @@ -1,16 +0,0 @@ -from socketserver import BaseRequestHandler -from typing import Any - - -class TCPRequestHandler(BaseRequestHandler): - - def log_message(self, format: str, *args: Any) -> None: - if self.server.app.canLog: # type: ignore - self.server.app.log(format % args) # type: ignore - else: - print(format % args) - - def handle(self): - self.log_message(f"Connection from {self.client_address}") - data = self.request.recv(1024) - self.log_message(f"Received {data}") diff --git a/projects/server/src/server/WebRequestHandler.py b/projects/server/src/server/WebRequestHandler.py deleted file mode 100644 index 920bc5eeb..000000000 --- a/projects/server/src/server/WebRequestHandler.py +++ /dev/null @@ -1,70 +0,0 @@ -from http.server import BaseHTTPRequestHandler -from typing import Any - - -class AuthLoginHandler: - - def __init__(self, request_handler: BaseHTTPRequestHandler, app: Any): - self.request_handler = request_handler - self.app = app - - def do_GET(self): - - print("AuthLoginHandler") - print(self.request_handler.query) # type: ignore - - self.request_handler.send_response(200) - self.request_handler.send_header("Content-type", "text/html") - self.request_handler.end_headers() - self.request_handler.wfile.write(b"Hello, world!") - - -urls = { - "/AuthLogin": AuthLoginHandler, -} - - -class WebRequestHandler(BaseHTTPRequestHandler): - - def log_message(self, format: str, *args: Any) -> None: - if self.server.app.canLog: # type: ignore - self.server.app.log(format % args) # type: ignore - else: - super().log_message(format, *args) - - def do_POST(self): - pass - - def do_PUT(self): - pass - - def do_DELETE(self): - pass - - def do_HEAD(self): - pass - - def do_GET(self): - - self.query = dict() - - query = dict() - if "?" in self.path: - self.extract_query_params(query) - - if self.path in urls: - try: - self.log_message(f"GET request,\nPath: {self.path}\n") - handler = urls[self.path] - handler(self, self.server.app).do_GET() # type: ignore - except Exception as e: - if self.server.app.canLog: # type: ignore - self.server.app.log(f"Server error: {e}") # type: ignore - self.send_error(500, "Server error") - - def extract_query_params(self, query): - self.path, query_string = self.path.split("?", 1) - for key_value in query_string.split("&"): - key, value = key_value.split("=") - query[key] = value - self.query = query diff --git a/projects/server/src/server/__init__.py b/projects/server/src/server/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/projects/server/src/server/env_default_action.py b/projects/server/src/server/env_default_action.py deleted file mode 100644 index d7ee65978..000000000 --- a/projects/server/src/server/env_default_action.py +++ /dev/null @@ -1,15 +0,0 @@ -import argparse -import os - - -class EnvDefault(argparse.Action): - def __init__(self, envvar, required=True, default=None, **kwargs): - if envvar: - if envvar in os.environ: - default = os.environ[envvar] - if required and default: - required = False - super(EnvDefault, self).__init__(default=default, required=required, **kwargs) - - def __call__(self, parser, namespace, values, option_string=None): - setattr(namespace, self.dest, values) diff --git a/projects/server/src/server/rusty_motors_server.py b/projects/server/src/server/rusty_motors_server.py deleted file mode 100644 index 4f6468736..000000000 --- a/projects/server/src/server/rusty_motors_server.py +++ /dev/null @@ -1,219 +0,0 @@ -import argparse -import tkinter as tk - -from server.TCPRequestHandler import TCPRequestHandler -from server.WebRequestHandler import WebRequestHandler -from server.env_default_action import EnvDefault -from server.setupTCPServer import setupTCPServer -from server.tkservers import tkHTTPServer -from select import poll, POLLIN -from socketserver import ThreadingTCPServer -from http.server import ThreadingHTTPServer -import sys - -root = tk.Tk() - - -class RustyMotorsServer(tk.Frame): - """ - A class representing the Rusty Motors Server. - - This server provides a graphical user interface (GUI) for controlling and monitoring - various servers used in the Rusty Motors project. - - Args: - master: The master widget. - - Attributes: - args: The parsed server arguments. - http_server: The HTTP server instance. - login_server: The login server instance. - persona_server: The persona server instance. - lobby_server: The lobby server instance. - mcots_server: The MCOTS server instance. - fdMapper: A dictionary mapping file descriptors to server instances. - poller: The poller instance for handling incoming connections. - - Extends: - tk.Frame - """ - - def __init__( - self, - args, - master=None, - ): - self.canLog = False - self.poll_interval = 100 - - self.args = args or self.parse_args() - - try: - self.initialize_gui_and_servers(master) - except Exception as e: - print(e) - sys.exit(1) - - def parse_args(self): - """ - Parse the command line arguments for the server. - - Returns: - args (argparse.Namespace): The parsed command line arguments. - """ - parser = argparse.ArgumentParser() - parser.add_argument( - "--server-address", - action=EnvDefault, - envvar="SERVER_ADDRESS", - default="0.0.0.0", - help="The address to bind the server to. Default: 0.0.0.0. \ - Can be set with the SERVER_ADDRESS environment variable.", - ) - parser.add_argument( - "--port", - action=EnvDefault, - envvar="PORT", - default=3000, - help="The port to bind the server to. Default: 3000. Can be set with the PORT environment variable.", - ) - parser.add_argument( - "--external-host", - action=EnvDefault, - envvar="EXTERNAL_HOST", - default="localhost", - help="The external host to tell clients to connect to. Default: localhost. \ - Can be set with the EXTERNAL_HOST environment variable.", - ) - return parser.parse_args() - - def log(self, message: str, type: str = "info"): - if self.canLog: - self.log_text.insert(tk.END, message, type) - self.log_text.insert(tk.END, "\n", type) - self.log_text.see(tk.END) - else: - print(message) - - def initialize_gui_and_servers(self, master): - self.initialize_gui(master) - - self.registerKeyboardBinding() - - self.initializeServers() - - def initialize_gui(self, master): - tk.Frame.__init__(self, master) - self.grid() - root.title("Rusty Motors Server") - tk.Label(self, text="Rusty Motors Server").grid(row=0, column=0) - tk.Button(self, text="Quit", command=self.shutdown).grid(row=1, column=1) - # Create a Label for log messages - self.log_label = tk.Label(self, text="Log messages will appear here") - # Create a scrollbar for the log - self.scrollbar = tk.Scrollbar(self, orient="vertical") - # Create a read-only Text widget to display the log - self.log_text = tk.Text( - self, - height=10, - width=50, - yscrollcommand=self.scrollbar.set, - wrap="word", - ) - self.log_text.tag_config("input", foreground="blue") - self.log_text.tag_config("error", foreground="red") - # Create an entry widget for user input - self.entry = tk.Entry(self, width=50) - - # Place the widgets on the grid - self.log_label.grid(row=2, column=0) - self.scrollbar.grid(row=3, column=1, sticky="ns") - self.log_text.grid(row=3, column=0) - self.entry.grid(row=4, column=0) - # Configure the scrollbar to scroll the log_text widget - self.scrollbar.config(command=self.log_text.yview) - self.canLog = True - - def processUserInput(self): - self.log(f"User input: {self.entry.get()}", "input") - self.entry.delete(0, tk.END) - - def initializeServers(self): - # Setup HTTP server - self.log(f"Starting HTTP server on {self.args.server_address}:{self.args.port}") - self.http_server = tkHTTPServer( - (self.args.server_address, int(self.args.port)), WebRequestHandler, self - ) - self.http_server.allow_reuse_address = True - self.http_server.server_bind() - self.http_server.socket.listen(5) - - try: - self.login_server = setupTCPServer(self, 8226, TCPRequestHandler) - self.persona_server = setupTCPServer(self, 8228, TCPRequestHandler) - self.lobby_server = setupTCPServer(self, 7003, TCPRequestHandler) - self.mcots_server = setupTCPServer(self, 43300, TCPRequestHandler) - except OSError as e: - self.canLog = False - raise Exception(f"Cannot bind to port {e}") - - self.fdMapper: dict[int, ThreadingHTTPServer | ThreadingTCPServer] = { - self.http_server.socket.fileno(): self.http_server, - self.login_server.fileno(): self.login_server, - self.persona_server.fileno(): self.persona_server, - self.lobby_server.fileno(): self.lobby_server, - self.mcots_server.fileno(): self.mcots_server, - } - - self.poller = poll() - self.poller.register(self.http_server.socket, POLLIN) - self.poller.register(self.login_server, POLLIN) - self.poller.register(self.persona_server, POLLIN) - self.poller.register(self.lobby_server, POLLIN) - self.poller.register(self.mcots_server, POLLIN) - self.log("Registered all sockets") - - def shutdown(self): - self.log("Shutting down servers...") - if hasattr(self, "http_server"): - self.http_server.server_close() - if hasattr(self, "login_server"): - self.login_server.server_close() - if hasattr(self, "persona_server"): - self.persona_server.server_close() - if hasattr(self, "lobby_server"): - self.lobby_server.server_close() - if hasattr(self, "mcots_server"): - self.mcots_server.server_close() - self.quit() - - def pollingProcess(self): - incoming = self.poller.poll(1) - - if len(incoming) == 0: - self.checkServersForData() - return - - for fd, event in incoming: - if event == POLLIN: - self.handle_incoming(fd) - - self.checkServersForData() - - def checkServersForData(self): - self.after(self.poll_interval, self.pollingProcess) - - def handle_incoming(self, fd): - server = self.fdMapper[fd] - self.log(f"Handling incoming connection on port {server.server_address[1]}") - server.handle_request() - - def registerKeyboardBinding(self): - self.master.bind("x", lambda event: self.shutdown()) - # On attempting to focuse on the log_entry widget, the focus will be set to the entry widget - self.log_text.bind("", lambda event: self.entry.focus_set()) - self.entry.bind("", lambda event: self.processUserInput()) - - def run(self): - self.checkServersForData() - self.mainloop() diff --git a/projects/server/src/server/setupTCPServer.py b/projects/server/src/server/setupTCPServer.py deleted file mode 100644 index 0ffdc998a..000000000 --- a/projects/server/src/server/setupTCPServer.py +++ /dev/null @@ -1,17 +0,0 @@ -from server.TCPRequestHandler import TCPRequestHandler -from server.tkservers import tkTCPServer - - -import tkinter as tk - -allowed_backlog = 5 - - -def setupTCPServer( - tkApp: tk.Frame, port: int, handler=TCPRequestHandler -) -> tkTCPServer: - server = tkTCPServer(("localhost", port), handler, tkApp) - server.allow_reuse_address = True - server.server_bind() - server.socket.listen(allowed_backlog) - return server diff --git a/projects/server/src/server/tkservers.py b/projects/server/src/server/tkservers.py deleted file mode 100644 index 6ab19ca02..000000000 --- a/projects/server/src/server/tkservers.py +++ /dev/null @@ -1,21 +0,0 @@ -from http.server import ThreadingHTTPServer -from socketserver import ThreadingTCPServer -import tkinter as tk - - -class tkTCPServer(ThreadingTCPServer): - def __init__(self, server_address, RequestHandlerClass, app: tk.Frame): - super().__init__(server_address, RequestHandlerClass, False) - self.app = app - - def fileno(self): - return self.socket.fileno() - - -class tkHTTPServer(ThreadingHTTPServer): - def __init__(self, server_address, RequestHandlerClass, app: tk.Frame): - super().__init__(server_address, RequestHandlerClass, False) - self.app = app - - def fileno(self): - return self.socket.fileno() diff --git a/projects/server/tests/__init__.py b/projects/server/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/projects/server/tests/rusty_motors_server_test.py b/projects/server/tests/rusty_motors_server_test.py deleted file mode 100644 index 3c4c03949..000000000 --- a/projects/server/tests/rusty_motors_server_test.py +++ /dev/null @@ -1,38 +0,0 @@ -from argparse import Namespace -from tkinter import Text -import unittest -from unittest.mock import MagicMock, patch -from server.rusty_motors_server import RustyMotorsServer - - -class TestRustyMotorsServer(unittest.TestCase): - - def test_shutdown(self): - args: Namespace = Namespace( - server_address="localhost", - port="3000", - ) - server = RustyMotorsServer(args) - with patch.object(server, "quit") as mock_quit: - server.shutdown() - mock_quit.assert_called_once() - - def test_messageLogger(self): - - # Create an instance of RustyMotorsServer - args: Namespace = Namespace( - server_address="localhost", - port="3000", - ) - server = RustyMotorsServer(args) - # Create a mock Text widget - server.log_text = MagicMock(spec=Text) - - # Call the messageLogger method with the mock Text widget - - server.log("Hello, World!") - - # Assert that the mock Text widget's insert method was called once - server.log_text.insert.was_called_with(1, "Hello, World!", "black") - - server.shutdown() diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index f426ab78f..000000000 --- a/pyproject.toml +++ /dev/null @@ -1,47 +0,0 @@ -[project] -name = "rusty-server" -version = "0.1.0" -description = "Default template for PDM package" -authors = [{ name = "Molly Draven", email = "drazi@duck.com" }] -dependencies = [ - "server @ file:///${PROJECT_ROOT}/projects/server", - "sentry-sdk>=2.7.1", - "Tcl>=0.2", # Needed for tkinter to work correctly -] -requires-python = "==3.12.*" -readme = "README.md" -license = { text = "AGPL-3.0" } - -[tool.black] -target-version = ['py37'] -include = '\.pyi?$' -# 'extend-exclude' excludes files or directories in addition to the defaults -extend-exclude = ''' -# A regex preceded with ^/ will apply only to files and directories -# in the root of the project. -( - ^/foo.py # exclude a file named foo.py in the root of the project - | .*_pb2.py # exclude autogenerated Protocol Buffer files anywhere in the project -) -''' - - -[tool.pdm] -distribution = false - -[tool.pdm.dev-dependencies] -dev = [ - "-e file:///${PROJECT_ROOT}/libs/serializable", - "-e file:///${PROJECT_ROOT}/projects/server", - "pre-commit>=3.7.1", - "black>=24.4.2", - "flake8>=7.1.0", - "flake8-black>=0.3.6", -] -test = ["pytest>=8.2.2", "coverage>=7.5.3"] - -[tool.pdm.scripts] -start = "rm-server.py" -lint = "make lint" -format = "make format" -test = "make test" diff --git a/rm-server.py b/rm-server.py deleted file mode 100755 index 256956fb5..000000000 --- a/rm-server.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 - - -from server.rusty_motors_server import RustyMotorsServer -from sentry_sdk.integrations.socket import SocketIntegration - -import sentry_sdk - -sentry_sdk.init( - dsn="https://3d28b6085dabc6e8ecd7b263df477ead@o1413557.ingest.us.sentry.io/4507356101476352", - # Set traces_sample_rate to 1.0 to capture 100% - # of transactions for tracing. - traces_sample_rate=1.0, - # Set profiles_sample_rate to 1.0 to profile 100% - # of sampled transactions. - # We recommend adjusting this value in production. - profiles_sample_rate=1.0, - integrations=[SocketIntegration()], -) - - -path = "/home/drazisil/Downloads/MCO/mcity.exe" - - -def main(): - print("Hello World!") - - server = RustyMotorsServer({}) - server.run() - - -if __name__ == "__main__": - main() diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 8e2a045c1..000000000 --- a/tox.ini +++ /dev/null @@ -1,11 +0,0 @@ -[flake8] -count = True -select = C,E,F,W,B,B950 -show_source = True -statistics = True -max-line-length = 127 -max-complexity = 10 -exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,.venv,.tox,.coverage -per-file-ignores = - # module level import not at top of file - ./tests/__init__.py: E402