From d7c1c287a5dd8a34e9199290bb8882a24eb61815 Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Wed, 11 Nov 2026 01:17:38 -0700 Subject: [PATCH 1/2] Document console_view's extra-argument exit and the unknown version console_view.py exits 2 when the environment ID is followed by further arguments, which the README and the module docstring did not mention; a main()-level test now covers it. The README also now says that usage reporting sends "unknown" as the version when version.txt cannot be read. Co-Authored-By: Claude Opus 5.5 --- README.md | 5 +++-- console_view.py | 3 ++- tests/test_console_view.py | 9 +++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index adbb261..975463e 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ python console_view.py 7 The environment ID is the required argument; `environments.json` records the ID of each environment created by `main.py`. The Viron server is expected at the same address as for `main.py` (see [Starting Viron](#starting-viron)). The application uses Viron's `LocationService`, so it needs the `Viron/` submodule and Requests, but not Pygame. -The exit status is `0` once the environment is printed. It is `1`, with a message, if the locations cannot be fetched or there are none, which is also how an ID unknown to Viron shows up, and `2`, with a usage line, if the argument is missing or is not an integer. `--help` or `-h` prints the usage line and exits with status `0` without contacting Viron. +The exit status is `0` once the environment is printed. It is `1`, with a message, if the locations cannot be fetched or there are none, which is also how an ID unknown to Viron shows up, and `2`, with a usage line, if the argument is missing, is not an integer, or is followed by further arguments. `--help` or `-h` prints the usage line and exits with status `0` without contacting Viron. Nothing is created in Viron, no file is written, and no usage is reported. Viron gives every grid the same coordinates, so the grids of an environment with several would be drawn on top of each other; environments created by `main.py` have one. @@ -300,7 +300,8 @@ The GIF at the top was recorded from an unmodified `python main.py 20` run under Usage reporting is on by default: Patchwork sends its name (`patchwork`), its version from `version.txt` and the events `startup` (once per launch) and `environment-created` (when a new environment is created through Viron) to [trace](https://danielstephenson.dev/usage-reporting) -at `https://trace.danielstephenson.dev`, so that it is known which versions are in use. Every +at `https://trace.danielstephenson.dev`, so that it is known which versions are in use. If +`version.txt` is missing, unreadable or empty, `unknown` is sent as the version instead. Every event also carries a random installation ID (the tag `install`) so installations can be counted rather than events; beyond that, nothing about you, your machine, your IP address, the grid size or the environments is sent. The report diff --git a/console_view.py b/console_view.py index dd7f8c1..f030900 100644 --- a/console_view.py +++ b/console_view.py @@ -8,7 +8,8 @@ python console_view.py The exit status is 0 if the environment was printed, 1 if it could not be fetched or has -no locations, and 2 if the argument is missing or is not an integer. +no locations, and 2 if the argument is missing, is not an integer, or is followed by +further arguments. """ import sys diff --git a/tests/test_console_view.py b/tests/test_console_view.py index fcf1076..8f6252d 100644 --- a/tests/test_console_view.py +++ b/tests/test_console_view.py @@ -68,6 +68,15 @@ def test_a_non_integer_argument_prints_the_usage_and_exits_two(self): self.assertEqual(status, 2) self.assertEqual(output, console_view.usage + "\n") + def test_a_further_argument_prints_the_usage_and_exits_two_without_reaching_viron(self): + locationService = fakeLocationService([]) + + status, output = runMain(["console_view.py", "7", "8"], locationService) + + self.assertEqual(status, 2) + self.assertEqual(output, console_view.usage + "\n") + locationService.get_locations_in_environment.assert_not_called() + def test_help_prints_the_usage_and_exits_zero_without_reaching_viron(self): for flag in ("--help", "-h"): with self.subTest(flag=flag), patch.object(console_view, "LocationService") as service: From 97c20e6b169c16addd3db96b785879e2150d2d4c Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Wed, 11 Nov 2026 01:18:55 -0700 Subject: [PATCH 2/2] Say only an unopenable version.txt falls back to unknown readVersion catches OSError alone; a version.txt that cannot be decoded raises a ValueError that buildClient turns into a disabled client, so "unreadable" overstated the fallback. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 975463e..11a31cf 100644 --- a/README.md +++ b/README.md @@ -301,7 +301,7 @@ Usage reporting is on by default: Patchwork sends its name (`patchwork`), its ve `version.txt` and the events `startup` (once per launch) and `environment-created` (when a new environment is created through Viron) to [trace](https://danielstephenson.dev/usage-reporting) at `https://trace.danielstephenson.dev`, so that it is known which versions are in use. If -`version.txt` is missing, unreadable or empty, `unknown` is sent as the version instead. Every +`version.txt` is missing, cannot be opened or is empty, `unknown` is sent as the version instead. Every event also carries a random installation ID (the tag `install`) so installations can be counted rather than events; beyond that, nothing about you, your machine, your IP address, the grid size or the environments is sent. The report