From 2b79f5a4f5a7198e404e17177dfe6a69e50fa2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Sa=CC=81nchez?= Date: Tue, 23 May 2023 11:44:06 -0700 Subject: [PATCH 001/266] Use trunk --- requirements/requirements-direct.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements/requirements-direct.txt b/requirements/requirements-direct.txt index e6353ccee..75b944ffa 100644 --- a/requirements/requirements-direct.txt +++ b/requirements/requirements-direct.txt @@ -5,7 +5,9 @@ cattrs==22.2.0 cryptography==40.0.2 hyperlink==21.0.0 jwcrypto==1.4.2 -klein==21.8.0 +#klein==21.8.0 +klein @ git+https://github.com/twisted/klein@trunk +#klein @ file:///Users/wsanchez/Developer/Twisted/klein PyMySQL==1.0.3 pyOpenSSL==23.1.1 PyYAML==6.0 From 5d78ac3cfcd68d414bbf193472874a28af3a648c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Sa=CC=81nchez?= Date: Tue, 23 May 2023 14:55:51 -0700 Subject: [PATCH 002/266] easy pickins' --- src/ims/element/_element.py | 8 +++++--- src/ims/ext/test/test_klein.py | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ims/element/_element.py b/src/ims/element/_element.py index 493a60b50..b3b885a65 100644 --- a/src/ims/element/_element.py +++ b/src/ims/element/_element.py @@ -176,7 +176,7 @@ def url(self, request: IRequest, tag: Tag) -> KleinRenderable: except AttributeError: raise ValueError(f"Unknown URL name: {name}") from None - text = url.asText() + text = cast(str, url.asText()) if tag.tagName == "json": return jsonTextFromObject(text) @@ -245,7 +245,7 @@ def events(self, request: IRequest, tag: Tag) -> KleinRenderable: """ Repeat an element once for each event, embedding the event ID. """ - return self._events(request, tag) + return cast(KleinRenderable, self._events(request, tag)) @renderer def events_reversed(self, request: IRequest, tag: Tag) -> KleinRenderable: @@ -253,7 +253,9 @@ def events_reversed(self, request: IRequest, tag: Tag) -> KleinRenderable: Repeat an element once for each event in reverse order, embedding the event ID. """ - return self._events(request, tag, reverse_order=True) + return cast( + KleinRenderable, self._events(request, tag, reverse_order=True) + ) @renderer async def events_list(self, request: IRequest, tag: Tag) -> KleinRenderable: diff --git a/src/ims/ext/test/test_klein.py b/src/ims/ext/test/test_klein.py index 5850b89d4..1f546b8ab 100644 --- a/src/ims/ext/test/test_klein.py +++ b/src/ims/ext/test/test_klein.py @@ -49,6 +49,7 @@ def test_static_etag(self) -> None: app.root(request) etags = request.responseHeaders.getRawHeaders("etag") + assert etags is not None self.assertTrue(len(etags) == 1, etags) etag = etags[0] self.assertTrue(etag) @@ -63,6 +64,7 @@ def test_static_cacheControl(self) -> None: app.root(request) etags = request.responseHeaders.getRawHeaders("cache-control") + assert etags is not None self.assertTrue(len(etags) == 1, etags) etag = etags[0] self.assertTrue(etag) From b6f23268822dc903eeec9a58468d7fbaab032ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Sa=CC=81nchez?= Date: Mon, 16 Oct 2023 19:06:58 -0700 Subject: [PATCH 003/266] Switch to Python 3.12 --- .github/workflows/cicd.yml | 22 +++++++++++----------- .github/workflows/deploy.yml | 4 ++-- .pre-commit-config.yaml | 10 +++++----- pyproject.toml | 2 +- tox.ini | 12 ++++++------ 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 01b6d44ba..9054b571b 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -40,7 +40,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - name: System Python Information uses: twisted/python-info-action@v1 @@ -86,7 +86,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - name: System Python Information uses: twisted/python-info-action@v1 @@ -132,7 +132,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - name: System Python Information uses: twisted/python-info-action@v1 @@ -179,7 +179,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - name: System Python Information uses: twisted/python-info-action@v1 @@ -225,7 +225,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - name: System Python Information uses: twisted/python-info-action@v1 @@ -270,7 +270,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - name: System Python Information uses: twisted/python-info-action@v1 @@ -299,13 +299,13 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] - python-version: ["3.11"] # Versions to test with coverage + python-version: ["3.12"] # Versions to test with coverage tox-prefix: ["coverage"] optional: [false] include: - # Test Python 3.12 beta but allow it to fail + # Test Python beta but allow it to fail - os: "ubuntu-latest" - python-version: "3.12.0-beta.4" + python-version: "3.13.0-alpha.1" optional: true tox-prefix: "test" @@ -404,7 +404,7 @@ jobs: - uses: "actions/setup-python@v4" if: ${{ matrix.tox-prefix == 'coverage' }} with: - python-version: "3.11" + python-version: "3.12" - name: "Upload coverage to Codecov" uses: "codecov/codecov-action@v3.1.4" @@ -561,7 +561,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - name: Deploy to staging run: ./bin/deploy staging diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 590538e6e..c2955c4a8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -36,7 +36,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.12" - name: System Python Information uses: twisted/python-info-action@v1 @@ -91,7 +91,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.12" - name: System Python Information uses: twisted/python-info-action@v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 549a1c527..d2792b6ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,13 +8,13 @@ repos: rev: "v3.15.0" hooks: - id: pyupgrade - args: ["--py310-plus"] + args: ["--py312-plus"] - repo: https://github.com/psf/black rev: "23.9.1" hooks: - id: black - args: ["--target-version", "py311"] + args: ["--target-version", "py312"] - repo: https://github.com/PyCQA/autoflake rev: "v2.2.1" @@ -32,12 +32,12 @@ repos: hooks: - id: flake8 additional_dependencies: - - flake8-bugbear==23.7.10 + - flake8-bugbear==23.9.16 - flake8-docstrings==1.7.0 - flake8-mutable==1.2.0 - flake8-pep3101==2.0.0 - pep8-naming==0.13.3 - - pycodestyle==2.11.0 + - pycodestyle==2.11.1 - pydocstyle==6.3.0 - pyflakes==3.1.0 @@ -46,7 +46,7 @@ repos: hooks: - id: yesqa additional_dependencies: - - flake8-bugbear==23.7.10 + - flake8-bugbear==23.9.16 - flake8-docstrings==1.7.0 - flake8-mutable==1.2.0 - flake8-pep3101==2.0.0 diff --git a/pyproject.toml b/pyproject.toml index 0c4c86147..daa59dc1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,4 +7,4 @@ build-backend = "setuptools.build_meta" [tool.black] line-length = 80 -target-version = ["py311"] +target-version = ["py312"] diff --git a/tox.ini b/tox.ini index 38bf736cb..6d4299d7f 100644 --- a/tox.ini +++ b/tox.ini @@ -2,8 +2,8 @@ envlist = lint, mypy, bandit - test-py312 - coverage-py311 + test-py313 + coverage-py312 coverage_report docs packaging @@ -13,7 +13,7 @@ skip_missing_interpreters = {tty:True:False} [default] -basepython = python3.11 +basepython = python3.12 deps = {test,coverage}: -r requirements/requirements-tests.txt @@ -37,8 +37,8 @@ description = run tests basepython = py: python - py311: python3.11 py312: python3.12 + py313: python3.13 deps = {[default]deps} @@ -128,7 +128,7 @@ commands = description = generate coverage report -depends = coverage-py{311,312} +depends = coverage-py{312,313} basepython = {[default]basepython} @@ -231,7 +231,7 @@ commands = description = check for potential packaging problems -depends = {test,coverage}-py{311,312} +depends = {test,coverage}-py{312,313} basepython = {[default]basepython} From 8fd8beec71f0e3235d1841b0890671056379829a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Sa=CC=81nchez?= Date: Mon, 16 Oct 2023 19:19:35 -0700 Subject: [PATCH 004/266] Update metadata --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ef53376e0..4d06a6cf5 100755 --- a/setup.py +++ b/setup.py @@ -62,8 +62,7 @@ "Intended Audience :: Other Audience", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Office/Business", ] From 7759a93e7fe9c00a86306d82b6cac5f857be5b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Sa=CC=81nchez?= Date: Mon, 16 Oct 2023 19:19:44 -0700 Subject: [PATCH 005/266] Upate Dockerfile --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e129576ad..c5e7633d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # ----------------------------------------------------------------------------- # This stage builds the build container. # ----------------------------------------------------------------------------- -FROM python:3.11.0-alpine3.16 as build +FROM python:3.12.0-alpine3.18 as build # Install compiler toolchain and libraries. RUN apk add --no-cache build-base libffi-dev libressl-dev @@ -35,7 +35,7 @@ RUN "${IMS_INSTALL_DIR}/bin/pip" --no-cache-dir install "${IMS_SOURCE_DIR}" # ----------------------------------------------------------------------------- # This stage builds the application container. # ----------------------------------------------------------------------------- -FROM python:3.11.0-alpine3.16 as application +FROM python:3.12.0-alpine3.18 as application # Paths ARG IMS_INSTALL_DIR="/opt/ims" @@ -53,7 +53,7 @@ RUN apk add --no-cache libressl # Allow Python to bind to privileged port numbers RUN apk add --no-cache libcap -RUN setcap "cap_net_bind_service=+ep" /usr/local/bin/python3.11 +RUN setcap "cap_net_bind_service=+ep" /usr/local/bin/python3.12 # Create server root and make that our working directory RUN install -o daemon -g daemon -d "${IMS_SERVER_ROOT}" From 50eae117f8a5805f2d92635cfcf8146dbe737462 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Nov 2023 04:32:04 +0000 Subject: [PATCH 006/266] Bump mypy from 1.5.1 to 1.7.1 Bumps [mypy](https://github.com/python/mypy) from 1.5.1 to 1.7.1. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.5.1...v1.7.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements/requirements-mypy.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/requirements-mypy.txt b/requirements/requirements-mypy.txt index faddf29fe..37785c2d6 100644 --- a/requirements/requirements-mypy.txt +++ b/requirements/requirements-mypy.txt @@ -1,6 +1,6 @@ # Note: mypy-zope pins the mypy version -mypy==1.5.1 +mypy==1.7.1 mypy-zope==1.0.1 types-PyMySQL==1.1.0.1 From 78b864428a22236fc18579efda1ba1015bb8c316 Mon Sep 17 00:00:00 2001 From: "Sean R. Abraham" Date: Mon, 15 Jan 2024 15:25:48 -0700 Subject: [PATCH 007/266] docs: change to working tox command "tox run -e exec" didn't work for me. It complained about "run" being an invalid subcommand. "tox -e exec" did work though. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 1b5d08054..6a1002409 100644 --- a/README.rst +++ b/README.rst @@ -49,7 +49,7 @@ To set up a configuration for development, start by copying the example configur To build and run the server (for development only):: - tox run -e exec + tox -e exec In your browser, open http://localhost:8080/ to reach the server. Log in as any user in the ``conf/directory.yaml`` directory file. In the ``conf/imsd.conf`` sample configuration file, the users ``Hardware`` and ``Loosy`` are administrators, and in the sample directory, all users have passwords that match their handles. You'll want to log in as one of those to set up an Event. From 74a9e2cb5a2dc62839895f475a0d9d4bafaa2e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Sa=CC=81nchez?= Date: Wed, 17 Jan 2024 10:15:32 -0800 Subject: [PATCH 008/266] Add instructions to install and update Tox with pipx. --- README.rst | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 6a1002409..a79d3a5f6 100644 --- a/README.rst +++ b/README.rst @@ -27,6 +27,13 @@ Running the Test Suite ~~~~~~~~~~~~~~~~~~~~~~ This project uses Tox_ for running tests. + +If you do not have tox installed, the recommended way is to use pipx_:: + + python3 -m pip install pipx + pipx install tox + pipx upgrade tox + To run all of the default test environments:: tox run @@ -49,7 +56,7 @@ To set up a configuration for development, start by copying the example configur To build and run the server (for development only):: - tox -e exec + tox run -e exec In your browser, open http://localhost:8080/ to reach the server. Log in as any user in the ``conf/directory.yaml`` directory file. In the ``conf/imsd.conf`` sample configuration file, the users ``Hardware`` and ``Loosy`` are administrators, and in the sample directory, all users have passwords that match their handles. You'll want to log in as one of those to set up an Event. @@ -68,8 +75,9 @@ Pull requests in GitHub will run all tests on Travis CI, and all are required to .. ------------------------------------------------------------------------- .. -.. _Twisted: https://twistedmatrix.com/ -.. _Klein: https://klein.readthedocs.io/ -.. _Tox: http://tox.readthedocs.io/ .. _Flake8: http://flake8.pycqa.org/ +.. _Klein: https://klein.readthedocs.io/ .. _Mypy: http://mypy.readthedocs.io/ +.. _pipx: https://pipx.pypa.io/stable/ +.. _Tox: http://tox.readthedocs.io/ +.. _Twisted: https://twistedmatrix.com/ From c7ac3d0bce50182413ec4d09eab0fb61d0686791 Mon Sep 17 00:00:00 2001 From: Sean Abraham Date: Mon, 15 Jan 2024 15:08:01 -0700 Subject: [PATCH 009/266] feat: help user not lose unsaved changes As things were, it was easy to accidentally navigate away from the incident page and lose your unsaved text. I know this would've saved me a lot of pain at Burning Man 2023, and I'm sure other people have been bitten by this problem too. I'm a JavaScript noob, so please feel free to suggest any changes. --- src/ims/element/static/incident.js | 8 ++++++++ src/ims/element/static/incident_report.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/ims/element/static/incident.js b/src/ims/element/static/incident.js index abbbae389..d2495828c 100644 --- a/src/ims/element/static/incident.js +++ b/src/ims/element/static/incident.js @@ -30,6 +30,14 @@ function initIncidentPage() { // Scroll to incident_report_add field $("html, body").animate({ scrollTop: $("#incident_report_add").offset().top }, 500); $("#incident_report_add").focus(); + + // Warn the user if they're about to navigate away with unsaved text. + window.addEventListener('beforeunload', function (e) { + if (document.getElementById("incident_report_add").value !== '') { + e.preventDefault(); + e.returnValue = ''; + } + }); } function loadedBody() { diff --git a/src/ims/element/static/incident_report.js b/src/ims/element/static/incident_report.js index a1010f652..b6da848e8 100644 --- a/src/ims/element/static/incident_report.js +++ b/src/ims/element/static/incident_report.js @@ -23,6 +23,14 @@ function initIncidentReportPage() { // Scroll to incident_report_add field $("html, body").animate({ scrollTop: $("#incident_report_add").offset().top }, 500); $("#incident_report_add").focus(); + + // Warn the user if they're about to navigate away with unsaved text. + window.addEventListener('beforeunload', function (e) { + if (document.getElementById("incident_report_add").value !== '') { + e.preventDefault(); + e.returnValue = ''; + } + }); } function loadedBody() { From 8055f6b2e15b09421bfc547a654b42c7411a2c91 Mon Sep 17 00:00:00 2001 From: Sean Abraham Date: Sun, 21 Jan 2024 11:50:33 -0700 Subject: [PATCH 010/266] fix: do case insensitive sort of Ranger handles Previously the list of Rangers in the "Add" dropdowns used case-sensitive sorting, so all the handles starting with a lowercase character were listed at the very end. This was rather unintuitive. localeCompare seems to be the preferred way to do this, and it uses the host's locale by default. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare --- src/ims/element/static/incident.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ims/element/static/incident.js b/src/ims/element/static/incident.js index abbbae389..fa037f50e 100644 --- a/src/ims/element/static/incident.js +++ b/src/ims/element/static/incident.js @@ -515,7 +515,7 @@ function drawRangers() { if (handles == undefined) { handles = []; } else { - handles.sort(); + handles.sort((a, b) => a.localeCompare(b)); } for (var i in handles) { @@ -545,7 +545,7 @@ function drawRangersToAdd() { for (var handle in personnel) { handles.push(handle); } - handles.sort(); + handles.sort((a, b) => a.localeCompare(b)); select.empty(); select.append($("