twobells 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {twobells-0.2.0/src/twobells.egg-info → twobells-0.2.2}/PKG-INFO +4 -4
- {twobells-0.2.0 → twobells-0.2.2}/README.md +3 -3
- {twobells-0.2.0 → twobells-0.2.2}/pyproject.toml +1 -1
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/net.py +110 -3
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/config.py +2 -2
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/enrich.py +25 -14
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/schema.py +1 -1
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/keytest.py +2 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/livebus.py +60 -33
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/build.py +40 -28
- {twobells-0.2.0 → twobells-0.2.2/src/twobells.egg-info}/PKG-INFO +4 -4
- {twobells-0.2.0 → twobells-0.2.2}/LICENSE +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/setup.cfg +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/__main__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/app.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/displays/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/displays/display.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/displays/screen.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/displays/waveshare.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/dotfont.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/flaps.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/fonts/Inter-ExtraBold.ttf +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/fonts/Inter-Regular.ttf +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/fonts/LICENSE +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/fonts/SHA256SUMS +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/panel.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/platformclock.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/positions.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/render.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/route.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/scroll.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/sign.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/speaker.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/splitflap.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/state.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/tft.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/themes.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/view.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/common.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/dev.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/main.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/run.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/serve.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/setup.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/timetable.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/announce.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/budget.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/calling.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/errors.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/files.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/model.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/osgb.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/polling.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/safexml.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/walk.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/words.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/area.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/collector.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/history.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/performance.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/repay.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/snapshot.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/alerts.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/api.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/app.css +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/area.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/board.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/disruptions.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/dom.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/extras.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/flap.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/fonts/DepartureboardDots.woff2 +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/fonts/LICENSE +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/fonts/SHA256SUMS +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/header.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/hero.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/history.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons/apple-touch-icon.png +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons/icon-192.png +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons/icon-512.png +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons/icon.svg +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/index.html +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/kiosk.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/live.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/look.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/main.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/manifest.webmanifest +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/map.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/measures.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/pa.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/performance.html +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/performance.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/platformclock.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/sheet.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/show.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/strip.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/theme.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/time.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/train.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/inter-4.1/InterVariable.woff2 +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/inter-4.1/LICENSE +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/inter-4.1/SHA256SUMS +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/LICENSE +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/SHA256SUMS +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/leaflet-src.esm.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/leaflet.css +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/weather.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/data/gb_stations.csv +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/data/naptan_area_grid.csv +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/emulation.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/emulator.html +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/fake.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/server.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/fetch/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/fetch/handoff.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/fetch/service.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/config.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/installs.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/keyresults.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/overlay.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/show.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/store.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/api.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/discover.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/lookups.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/checks.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/folder.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/runner.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/worker.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/bods.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/bodsbus.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/darwin.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/disruptions.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/holidays.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/lastbus.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/transportapi.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/weather.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/model.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/roads.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/routesetup.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/version.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/__init__.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/auth.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/formpages.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/groupform.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/icons.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/keyspage.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/keystate.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/netguard.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/overview.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/places.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/server.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/settings.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/settingsite.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/status.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/web.css +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/windowrows.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/api.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/finish.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/home.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/index.html +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/keys.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/maps.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/presets.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/roads.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/say.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/state.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/station.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/steps.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/stops.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/views.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/walk.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/wizard.css +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/wizard.js +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/SOURCES.txt +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/dependency_links.txt +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/entry_points.txt +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/requires.txt +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/top_level.txt +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/tests/test_deploy.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/tests/test_docs.py +0 -0
- {twobells-0.2.0 → twobells-0.2.2}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: twobells
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Two Bells: know when to leave. Train and bus departures for Great Britain, on an e-paper or HDMI board on a Raspberry Pi and on a web dashboard, installed on a Pi, in Docker or on a desktop
|
|
5
5
|
Author: Albert Cornelissen
|
|
6
6
|
License-Expression: MIT
|
|
@@ -47,7 +47,7 @@ Dynamic: license-file
|
|
|
47
47
|
One install is one app with two views of the same departures:
|
|
48
48
|
|
|
49
49
|
- **The board:** a Raspberry Pi with a four-colour Inky pHAT (250x122). The app also draws for a Waveshare 10.85" e-Paper (G) (1360x480), a Waveshare 7.9" HDMI screen (1280x400, on its side) and an 11.3" HDMI bar screen (1920x440); those are tested in software but not yet on the hardware.
|
|
50
|
-
- **The dashboard:** a web page for a phone or computer at home, with the next 10 trains and buses, calling points, bus strips and maps, the weather, disruptions and
|
|
50
|
+
- **The dashboard:** a web page for a phone or computer at home, with the next 10 trains and buses, calling points and coaches, bus strips and maps, the weather, disruptions, punctuality history, a Performance page with Delay Repay, and station announcements.
|
|
51
51
|
|
|
52
52
|
A Pi can run either view or both; Docker and a desktop run the dashboard. Each install has one settings site, at `/settings` on port 8090, with one password and a setup wizard that finds your station, stops, walk times and bus companies from your postcode. The examples use Glossop, with trains to Manchester and buses from two nearby stops (`examples/glossop.toml`).
|
|
53
53
|
|
|
@@ -79,7 +79,7 @@ Where there is room, the line runs across the page with each train placed on it:
|
|
|
79
79
|
|
|
80
80
|
Light, dark, the amber Dot matrix look, the white and yellow TFT look or the Split-flap look, at any size from a phone to a wall tablet (`/?kiosk`):
|
|
81
81
|
|
|
82
|
-

|
|
83
83
|
|
|
84
84
|
## The board
|
|
85
85
|
|
|
@@ -91,7 +91,7 @@ On the 10.85" e-paper there is room for platforms (as the app draws it; not yet
|
|
|
91
91
|
|
|
92
92
|

|
|
93
93
|
|
|
94
|
-
An HDMI screen redraws every second, with a running clock and countdowns, and a page showing where your next bus is (again as the app draws it, not yet tried on a real screen):
|
|
94
|
+
An HDMI screen redraws every second, with a running clock and countdowns, two more looks (`tft`, white and yellow on black, and `flap`, a split-flap board whose tiles turn), and if you want them the first train's calling points, a platform clock page and station announcements through a speaker. It also has a page showing where your next bus is (again as the app draws it, not yet tried on a real screen):
|
|
95
95
|
|
|
96
96
|

|
|
97
97
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
One install is one app with two views of the same departures:
|
|
14
14
|
|
|
15
15
|
- **The board:** a Raspberry Pi with a four-colour Inky pHAT (250x122). The app also draws for a Waveshare 10.85" e-Paper (G) (1360x480), a Waveshare 7.9" HDMI screen (1280x400, on its side) and an 11.3" HDMI bar screen (1920x440); those are tested in software but not yet on the hardware.
|
|
16
|
-
- **The dashboard:** a web page for a phone or computer at home, with the next 10 trains and buses, calling points, bus strips and maps, the weather, disruptions and
|
|
16
|
+
- **The dashboard:** a web page for a phone or computer at home, with the next 10 trains and buses, calling points and coaches, bus strips and maps, the weather, disruptions, punctuality history, a Performance page with Delay Repay, and station announcements.
|
|
17
17
|
|
|
18
18
|
A Pi can run either view or both; Docker and a desktop run the dashboard. Each install has one settings site, at `/settings` on port 8090, with one password and a setup wizard that finds your station, stops, walk times and bus companies from your postcode. The examples use Glossop, with trains to Manchester and buses from two nearby stops (`examples/glossop.toml`).
|
|
19
19
|
|
|
@@ -45,7 +45,7 @@ Where there is room, the line runs across the page with each train placed on it:
|
|
|
45
45
|
|
|
46
46
|
Light, dark, the amber Dot matrix look, the white and yellow TFT look or the Split-flap look, at any size from a phone to a wall tablet (`/?kiosk`):
|
|
47
47
|
|
|
48
|
-

|
|
49
49
|
|
|
50
50
|
## The board
|
|
51
51
|
|
|
@@ -57,7 +57,7 @@ On the 10.85" e-paper there is room for platforms (as the app draws it; not yet
|
|
|
57
57
|
|
|
58
58
|

|
|
59
59
|
|
|
60
|
-
An HDMI screen redraws every second, with a running clock and countdowns, and a page showing where your next bus is (again as the app draws it, not yet tried on a real screen):
|
|
60
|
+
An HDMI screen redraws every second, with a running clock and countdowns, two more looks (`tft`, white and yellow on black, and `flap`, a split-flap board whose tiles turn), and if you want them the first train's calling points, a platform clock page and station announcements through a speaker. It also has a page showing where your next bus is (again as the app draws it, not yet tried on a real screen):
|
|
61
61
|
|
|
62
62
|

|
|
63
63
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "twobells"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "Two Bells: know when to leave. Train and bus departures for Great Britain, on an e-paper or HDMI board on a Raspberry Pi and on a web dashboard, installed on a Pi, in Docker or on a desktop"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import io
|
|
6
6
|
import json
|
|
7
7
|
import time
|
|
8
|
+
import zlib
|
|
8
9
|
from collections.abc import Iterator, Mapping
|
|
9
10
|
from functools import partial
|
|
10
11
|
from http.client import HTTPConnection, HTTPSConnection
|
|
@@ -12,6 +13,7 @@ from urllib.error import HTTPError
|
|
|
12
13
|
from urllib.parse import urlsplit
|
|
13
14
|
from urllib.request import (
|
|
14
15
|
AbstractHTTPHandler,
|
|
16
|
+
BaseHandler,
|
|
15
17
|
HTTPDefaultErrorHandler,
|
|
16
18
|
HTTPErrorProcessor,
|
|
17
19
|
HTTPHandler,
|
|
@@ -164,13 +166,118 @@ class _HTTPSHandler(_Deadlines, HTTPSHandler):
|
|
|
164
166
|
pass
|
|
165
167
|
|
|
166
168
|
|
|
169
|
+
# Content-Encoding. Nothing here asks for a compressed answer (http.client
|
|
170
|
+
# sends "Accept-Encoding: identity"), but a service may send one anyway: the
|
|
171
|
+
# Rail Data Marketplace gzips its Knowledgebase incidents. Every answer is
|
|
172
|
+
# read decoded, as it arrives, so a caller's cap on what it reads is a cap on
|
|
173
|
+
# the decoded size: a small answer that would inflate to gigabytes (a gzip
|
|
174
|
+
# bomb) is never inflated past what the caller asked for.
|
|
175
|
+
|
|
176
|
+
_GZIP = 16 + zlib.MAX_WBITS # zlib's wbits for gzip's header and trailer
|
|
177
|
+
_DECODERS = {"gzip": _GZIP, "x-gzip": _GZIP, "deflate": zlib.MAX_WBITS} # deflate is zlib's format
|
|
178
|
+
_RAW_CHUNK = 1 << 16 # compressed bytes read at a time
|
|
179
|
+
_BROKEN = "The service sent a compressed answer that is broken or cut short"
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class BadEncoding(ValueError):
|
|
183
|
+
"""The answer was in a Content-Encoding this app doesn't read, or its
|
|
184
|
+
compressed body was broken."""
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _wbits(content_encoding: str) -> int | None:
|
|
188
|
+
"""zlib's wbits for a Content-Encoding header's value; None for an
|
|
189
|
+
answer sent as it is. BadEncoding for anything else, a chain of
|
|
190
|
+
encodings included."""
|
|
191
|
+
codings = [part.strip().lower() for part in content_encoding.split(",")]
|
|
192
|
+
codings = [coding for coding in codings if coding and coding != "identity"]
|
|
193
|
+
if not codings:
|
|
194
|
+
return None
|
|
195
|
+
if len(codings) == 1 and codings[0] in _DECODERS:
|
|
196
|
+
return _DECODERS[codings[0]]
|
|
197
|
+
raise BadEncoding("The service sent its answer in a form this app can't read "
|
|
198
|
+
"(a Content-Encoding other than gzip or deflate)")
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class _Decoded:
|
|
202
|
+
"""A response whose body is read decoded. read(size) inflates no more
|
|
203
|
+
than `size` bytes however small the compressed answer, and reads the
|
|
204
|
+
response a chunk at a time, so its deadline still holds. Everything else
|
|
205
|
+
(status, headers, closing) is the response's own."""
|
|
206
|
+
|
|
207
|
+
def __init__(self, response, wbits: int):
|
|
208
|
+
self._response = response
|
|
209
|
+
self._wbits = wbits
|
|
210
|
+
self._inflate = zlib.decompressobj(wbits)
|
|
211
|
+
self._pending = b"" # read from the response, not yet inflated
|
|
212
|
+
|
|
213
|
+
def __getattr__(self, name: str):
|
|
214
|
+
return getattr(self._response, name)
|
|
215
|
+
|
|
216
|
+
def __enter__(self):
|
|
217
|
+
return self
|
|
218
|
+
|
|
219
|
+
def __exit__(self, *exc) -> None:
|
|
220
|
+
self._response.close()
|
|
221
|
+
|
|
222
|
+
def read(self, size: int = -1) -> bytes:
|
|
223
|
+
if size is None or size < 0:
|
|
224
|
+
raise ValueError("A compressed answer is read a size at a time")
|
|
225
|
+
decoded = bytearray()
|
|
226
|
+
while len(decoded) < size:
|
|
227
|
+
ended = False
|
|
228
|
+
if not self._pending:
|
|
229
|
+
self._pending = self._response.read(_RAW_CHUNK)
|
|
230
|
+
ended = not self._pending
|
|
231
|
+
if self._inflate.eof:
|
|
232
|
+
if ended:
|
|
233
|
+
break
|
|
234
|
+
if self._wbits != _GZIP: # deflate is one stream; gzip may be several, one after another
|
|
235
|
+
raise BadEncoding(_BROKEN)
|
|
236
|
+
self._inflate = zlib.decompressobj(self._wbits)
|
|
237
|
+
try:
|
|
238
|
+
data = self._inflate.decompress(self._pending, size - len(decoded))
|
|
239
|
+
except zlib.error:
|
|
240
|
+
raise BadEncoding(_BROKEN) from None
|
|
241
|
+
self._pending = self._inflate.unused_data if self._inflate.eof else self._inflate.unconsumed_tail
|
|
242
|
+
decoded += data
|
|
243
|
+
if ended and not data and not self._inflate.eof:
|
|
244
|
+
raise BadEncoding(_BROKEN) # the answer stopped part way through
|
|
245
|
+
return bytes(decoded)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
class _ContentDecoding(BaseHandler):
|
|
249
|
+
"""Gives every answer as its decoded body, but for a redirect, whose body
|
|
250
|
+
urllib reads whole and throws away. It comes before HTTPErrorProcessor,
|
|
251
|
+
so an error's body, which the key test reads for clues, is decoded too;
|
|
252
|
+
an error in an encoding this app can't read keeps its status, its body
|
|
253
|
+
as sent."""
|
|
254
|
+
|
|
255
|
+
handler_order = 900 # HTTPErrorProcessor's is 1000
|
|
256
|
+
|
|
257
|
+
def http_response(self, request, response):
|
|
258
|
+
code = response.code
|
|
259
|
+
if 300 <= code < 400:
|
|
260
|
+
return response
|
|
261
|
+
try:
|
|
262
|
+
wbits = _wbits(", ".join(response.headers.get_all("Content-Encoding") or []))
|
|
263
|
+
except BadEncoding:
|
|
264
|
+
if code >= 400:
|
|
265
|
+
return response
|
|
266
|
+
response.close()
|
|
267
|
+
raise
|
|
268
|
+
return response if wbits is None else _Decoded(response, wbits)
|
|
269
|
+
|
|
270
|
+
https_response = http_response
|
|
271
|
+
|
|
272
|
+
|
|
167
273
|
def _build_opener() -> OpenerDirector:
|
|
168
274
|
"""urllib's build_opener always adds file:, ftp: and data: handlers; this
|
|
169
275
|
opener has only http and https, so any other address fails as an
|
|
170
|
-
unknown url type, wherever it came from (a redirect included).
|
|
276
|
+
unknown url type, wherever it came from (a redirect included). Every
|
|
277
|
+
answer comes decoded from its Content-Encoding."""
|
|
171
278
|
opener = OpenerDirector()
|
|
172
279
|
for handler in (UnknownHandler, HTTPDefaultErrorHandler, SafeRedirects, _HTTPHandler, _HTTPSHandler,
|
|
173
|
-
HTTPErrorProcessor):
|
|
280
|
+
_ContentDecoding, HTTPErrorProcessor):
|
|
174
281
|
opener.add_handler(handler())
|
|
175
282
|
return opener
|
|
176
283
|
|
|
@@ -242,7 +349,7 @@ def get_bytes(url: str, max_bytes: int, timeout: float = 15.0, headers: dict | N
|
|
|
242
349
|
with urlopen(request, timeout=timeout) as response:
|
|
243
350
|
body = response.read(max_bytes + 1)
|
|
244
351
|
if len(body) > max_bytes:
|
|
245
|
-
raise
|
|
352
|
+
raise TooLarge(f"Response larger than {max_bytes} bytes")
|
|
246
353
|
return body
|
|
247
354
|
|
|
248
355
|
|
|
@@ -93,7 +93,7 @@ class DashboardOptions:
|
|
|
93
93
|
|
|
94
94
|
state_dir: str | None = None
|
|
95
95
|
train_rows: int = 10
|
|
96
|
-
bus_rows: int =
|
|
96
|
+
bus_rows: int = 15 # about half an hour across five stops
|
|
97
97
|
train_interval_seconds: int = 60
|
|
98
98
|
bus_interval_seconds: int = 30
|
|
99
99
|
weather_interval_minutes: int = 30
|
|
@@ -174,7 +174,7 @@ def dashboard_options(data: dict) -> DashboardOptions:
|
|
|
174
174
|
return DashboardOptions(
|
|
175
175
|
state_dir=state_dir,
|
|
176
176
|
train_rows=_ranged(section, "train_rows", 10, 1, _MAX_ROWS),
|
|
177
|
-
bus_rows=_ranged(section, "bus_rows",
|
|
177
|
+
bus_rows=_ranged(section, "bus_rows", 15, 1, _MAX_ROWS),
|
|
178
178
|
train_interval_seconds=_whole(section, "train_interval_seconds", 60, _WHERE, least=30),
|
|
179
179
|
bus_interval_seconds=_whole(section, "bus_interval_seconds", 30, _WHERE, least=15),
|
|
180
180
|
weather_interval_minutes=_whole(section, "weather_interval_minutes", 30, _WHERE, least=10),
|
|
@@ -20,7 +20,9 @@ block, or else guessed by line) is shown as a line of its own ("Bus
|
|
|
20
20
|
arriving from Ashton, 4 min late (due 23:29)"), with the facts from its
|
|
21
21
|
tracker: where it is and how late. Either way the departure is live, and
|
|
22
22
|
livebus carries the bus's lateness on to the departure's time; `followed`
|
|
23
|
-
tells the API which it was.
|
|
23
|
+
tells the API which it was. The same journey's later stops of yours have
|
|
24
|
+
the same bus, named arriving where the journey starts ("Bus arriving at
|
|
25
|
+
Henry Street from Ashton, ...").
|
|
24
26
|
|
|
25
27
|
Ghost buses. A bus due within GHOST_WITHIN with no live bus placed on its
|
|
26
28
|
journey is flagged, since trackers usually show up well before then. Not
|
|
@@ -139,8 +141,10 @@ def _origin(placed: LiveJourney, positions: dict[str, StopPosition]) -> str | No
|
|
|
139
141
|
return _clean(placed.vehicle.origin_name)
|
|
140
142
|
|
|
141
143
|
|
|
142
|
-
def _where(placed: LiveJourney,
|
|
143
|
-
"""Where the inbound bus is, as the route strip says it: "4 stops away"
|
|
144
|
+
def _where(placed: LiveJourney, live: LiveDeparture, positions: dict[str, StopPosition]) -> str:
|
|
145
|
+
"""Where the inbound bus is, as the route strip says it: "4 stops away"
|
|
146
|
+
from the end of its journey, then "At your stop", or, for a later stop
|
|
147
|
+
of the departure's journey, at the stop it is in at ("At Henry Street")."""
|
|
144
148
|
calls = placed.journey.calls
|
|
145
149
|
away = (len(calls) - 1) - math.floor(placed.progress.at + 0.02)
|
|
146
150
|
if away == 1:
|
|
@@ -148,35 +152,42 @@ def _where(placed: LiveJourney, stop: str, positions: dict[str, StopPosition]) -
|
|
|
148
152
|
if away > 1:
|
|
149
153
|
return f"{away} stops away"
|
|
150
154
|
end = calls[-1].atco
|
|
151
|
-
if end ==
|
|
155
|
+
if live.call_index == 0 and (end == live.journey.origin.atco or end not in positions):
|
|
152
156
|
return "At your stop"
|
|
153
|
-
|
|
157
|
+
for atco in (end, live.journey.origin.atco):
|
|
158
|
+
if atco in positions:
|
|
159
|
+
return f"At {positions[atco].name}"
|
|
160
|
+
return "Waiting to start"
|
|
154
161
|
|
|
155
162
|
|
|
156
163
|
def inbound(live: LiveDeparture, positions: dict[str, StopPosition]) -> dict | None:
|
|
157
|
-
"""The bus coming in to work a departure that starts at your stop,
|
|
158
|
-
livebus found it, or None
|
|
159
|
-
|
|
160
|
-
line; either makes the
|
|
164
|
+
"""The bus coming in to work a departure that starts at your stop, or a
|
|
165
|
+
later stop of yours on the same journey, as livebus found it, or None
|
|
166
|
+
(see the module's notes). `followed` says whether it was followed by
|
|
167
|
+
the timetable's block rather than guessed by line; either makes the
|
|
168
|
+
departure live."""
|
|
161
169
|
coming = live.inbound
|
|
162
170
|
if coming is None:
|
|
163
171
|
return None
|
|
164
172
|
origin = _origin(coming.bus, positions)
|
|
165
173
|
due = coming.arrives.strftime("%H:%M")
|
|
174
|
+
start = positions.get(live.journey.origin.atco) if live.call_index > 0 else None
|
|
166
175
|
return {
|
|
167
176
|
"from": origin,
|
|
168
177
|
"due": due,
|
|
169
178
|
"late_min": coming.late,
|
|
170
|
-
"where": _where(coming.bus, live
|
|
171
|
-
"text": inbound_text(origin, coming.late, due),
|
|
179
|
+
"where": _where(coming.bus, live, positions),
|
|
180
|
+
"text": inbound_text(origin, coming.late, due, start.name if start is not None else None),
|
|
172
181
|
"followed": coming.followed,
|
|
173
182
|
}
|
|
174
183
|
|
|
175
184
|
|
|
176
|
-
def inbound_text(origin: str | None, late: int, due: str) -> str:
|
|
185
|
+
def inbound_text(origin: str | None, late: int, due: str, start: str | None = None) -> str:
|
|
177
186
|
"""The inbound bus in words for the row: "Bus arriving from Ashton, 4 min
|
|
178
|
-
late (due 23:29)". Its own lateness and time, never a time for the
|
|
179
|
-
|
|
187
|
+
late (due 23:29)". Its own lateness and time, never a time for the
|
|
188
|
+
departure. `start` names the stop it arrives at, the journey's first, for
|
|
189
|
+
a row at a later stop: "Bus arriving at Henry Street from Ashton, ..."."""
|
|
190
|
+
coming = "Bus arriving" + (f" at {start}" if start else "") + (f" from {origin}" if origin else "")
|
|
180
191
|
return f"{coming}, {f'{late} min late' if late else 'on time'} (due {due})"
|
|
181
192
|
|
|
182
193
|
|
|
@@ -529,7 +529,7 @@ def fields(display: str = "inky", theme: str = "sign") -> tuple[Field, ...]:
|
|
|
529
529
|
"number", hint=_LISTED, default=10, needs="train", page="dashboard", heading="Departures",
|
|
530
530
|
width="2"),
|
|
531
531
|
Field("dashboard_bus_rows", "dashboard", "dashboard", "bus_rows", "Most buses listed", number(1, 20),
|
|
532
|
-
"number", hint=_LISTED, default=
|
|
532
|
+
"number", hint=_LISTED, default=15, needs="bus", page="dashboard", heading="Departures",
|
|
533
533
|
width="2"),
|
|
534
534
|
Field("row_strips", "dashboard", "dashboard", "row_strips", "Position strips in each row", on_off, "radios",
|
|
535
535
|
hint="A small drawing of the stops in each departure row, with the train or bus where it is, while "
|
|
@@ -134,6 +134,8 @@ def _call(fetch: Callable[[str, Mapping[str, str]], _Body], url: str, headers: M
|
|
|
134
134
|
return fetch(url, headers)
|
|
135
135
|
except HTTPError as error:
|
|
136
136
|
raise _Outcome(_refused(error, service)) from None
|
|
137
|
+
except net.BadEncoding: # compressed in a way this can't read, or broken
|
|
138
|
+
raise _Outcome(_unreadable(service)) from None
|
|
137
139
|
except TimeoutError: # socket.timeout too
|
|
138
140
|
raise _Outcome(_down(service, _SLOW)) from None
|
|
139
141
|
except URLError as error:
|
|
@@ -14,10 +14,14 @@ bus. If that bus is placed (matched to that journey, or sending the same
|
|
|
14
14
|
block as its BlockRef), the departure is live too, marked inbound ("Bus on
|
|
15
15
|
its way, due in 6 min"): expected when that bus gets in plus TURNAROUND,
|
|
16
16
|
never before its time; once in, on time, or, that gone, any minute. Only
|
|
17
|
-
a
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
a journey whose first stop is yours is followed in, and the same bus goes
|
|
18
|
+
with it to its later stops of yours until it is placed on the journey:
|
|
19
|
+
expected at each the timetable's run time from the first stop after it
|
|
20
|
+
is expected to leave there, so never before its time either. Its words
|
|
21
|
+
count down to the bus getting to your stop. A bus still in INBOUND_WINDOW
|
|
22
|
+
after the time at the first stop, still on the journey before, has laid
|
|
23
|
+
over or gone out of service: it is let go at every stop, and the departure
|
|
24
|
+
goes as one with no bus seen would. The block is a hint, never trusted blindly: the
|
|
21
25
|
journey before must be the same operator's, on the same service day, the
|
|
22
26
|
one just before it in the block, and end at the departure's first stop, or
|
|
23
27
|
within NEAR_M of it, up to INBOUND_WINDOW before it leaves. If that bus
|
|
@@ -301,8 +305,9 @@ class LiveJourney:
|
|
|
301
305
|
|
|
302
306
|
@dataclass(frozen=True)
|
|
303
307
|
class Inbound:
|
|
304
|
-
"""The bus coming in to work a
|
|
305
|
-
on the journey before (see the module's notes).
|
|
308
|
+
"""The bus coming in to work a journey that starts at your stop, placed
|
|
309
|
+
on the journey before (see the module's notes). Its times are at the
|
|
310
|
+
end of the journey before, the departure's first stop."""
|
|
306
311
|
|
|
307
312
|
bus: LiveJourney
|
|
308
313
|
# By the block: the same bus. False for a guess by line. Either makes the
|
|
@@ -345,8 +350,8 @@ class LiveDeparture:
|
|
|
345
350
|
expected: datetime # leaves plus any lateness, board-local without a zone
|
|
346
351
|
progress: Progress | None # None when no bus was placed on the journey
|
|
347
352
|
vehicle: Vehicle | None # the bus behind progress
|
|
348
|
-
# The bus coming in to work it, for a
|
|
349
|
-
#
|
|
353
|
+
# The bus coming in to work it, for a journey starting at your stop with
|
|
354
|
+
# no bus placed on it, at that stop and its later ones (see the module's notes).
|
|
350
355
|
inbound: Inbound | None = None
|
|
351
356
|
|
|
352
357
|
@property
|
|
@@ -437,7 +442,8 @@ def live_board(
|
|
|
437
442
|
with its delay and stays on the board however late; one that has passed
|
|
438
443
|
your stop is dropped. A departure whose bus is followed in (see the
|
|
439
444
|
module's notes) is shown as late as that bus makes it, until a minute
|
|
440
|
-
after then, or, once in, until INBOUND_WINDOW after its time
|
|
445
|
+
after then, or, once in, until INBOUND_WINDOW after its journey's time
|
|
446
|
+
at the first stop. Without
|
|
441
447
|
either, the timetabled time is shown as UNKNOWN until a minute after it.
|
|
442
448
|
"""
|
|
443
449
|
if now.tzinfo is None:
|
|
@@ -469,19 +475,24 @@ def live_board(
|
|
|
469
475
|
if journey.inbound_only or not heading_to(journey.destination, directions):
|
|
470
476
|
continue # inbound-only journeys are there to find buses coming in, never as rows
|
|
471
477
|
progress, vehicle = live.get((day, id(journey)), (None, None))
|
|
478
|
+
starts = midnight + timedelta(minutes=journey.origin.minute)
|
|
479
|
+
inbound = None
|
|
480
|
+
if progress is None and journey.origin.atco in labels:
|
|
481
|
+
inbound = follow.bus_in(journey, day)
|
|
482
|
+
if inbound is not None and inbound.is_in and local_now > starts + INBOUND_WINDOW:
|
|
483
|
+
inbound = None # still in long after its time: laid over or out of service
|
|
472
484
|
for k, call in enumerate(journey.calls[:-1]): # the last call is where it terminates
|
|
473
485
|
leaves = midnight + timedelta(minutes=call.minute)
|
|
474
486
|
if progress is not None and progress.at > k + PASSED_MARGIN:
|
|
475
487
|
continue # the bus has been past this stop
|
|
476
|
-
|
|
477
|
-
if inbound is not None and inbound.is_in and local_now > leaves + INBOUND_WINDOW:
|
|
478
|
-
inbound = None # still in long after its time: laid over or out of service
|
|
479
|
-
if progress is None and _expected(leaves, None, inbound, local_now) < local_now - GRACE:
|
|
488
|
+
if progress is None and _expected(leaves, None, inbound, local_now, starts) < local_now - GRACE:
|
|
480
489
|
continue
|
|
481
490
|
if leaves > local_now + HORIZON:
|
|
482
491
|
continue
|
|
483
492
|
for label in labels.get(call.atco, ()):
|
|
484
|
-
found.append(
|
|
493
|
+
found.append(
|
|
494
|
+
_departure(journey, day, k, leaves, progress, vehicle, label, inbound, local_now, starts)
|
|
495
|
+
)
|
|
485
496
|
found.sort(key=lambda live: (live.expected, live.leaves, live.departure.stop, live.journey.line))
|
|
486
497
|
return found[:rows], list(placed.values())
|
|
487
498
|
|
|
@@ -619,18 +630,23 @@ class _Follow:
|
|
|
619
630
|
return bool(block) and all(other.origin.minute >= journey.origin.minute for other in block)
|
|
620
631
|
|
|
621
632
|
|
|
622
|
-
def _expected(
|
|
633
|
+
def _expected(
|
|
634
|
+
leaves: datetime, placed: Progress | None, inbound: Inbound | None, now: datetime, starts: datetime
|
|
635
|
+
) -> datetime:
|
|
623
636
|
"""When a departure is expected: as late as its bus is, or, followed in,
|
|
624
637
|
TURNAROUND after its bus gets in; never before its time. A bus already
|
|
625
638
|
in is no later, however long it has waited: it leaves on time, or, that
|
|
626
|
-
gone, any minute `now` (board-local).
|
|
639
|
+
gone, any minute `now` (board-local). `starts` is when the journey
|
|
640
|
+
leaves its first stop: a bus followed in is expected at a later stop the
|
|
641
|
+
timetable's run time from there after it is expected to leave."""
|
|
627
642
|
if placed is not None:
|
|
628
643
|
return leaves + timedelta(minutes=_late_minutes(placed.delay))
|
|
629
644
|
if inbound is None:
|
|
630
645
|
return leaves
|
|
646
|
+
run = leaves - starts
|
|
631
647
|
if inbound.is_in:
|
|
632
|
-
return max(
|
|
633
|
-
return max(
|
|
648
|
+
return max(starts, now.replace(second=0, microsecond=0)) + run
|
|
649
|
+
return max(starts, inbound.arrives + TURNAROUND) + run
|
|
634
650
|
|
|
635
651
|
|
|
636
652
|
def _departure(
|
|
@@ -643,10 +659,11 @@ def _departure(
|
|
|
643
659
|
label: str,
|
|
644
660
|
inbound: Inbound | None,
|
|
645
661
|
now: datetime,
|
|
662
|
+
starts: datetime,
|
|
646
663
|
) -> LiveDeparture:
|
|
647
664
|
"""A board row for the k-th call of a journey, and what it came from, at
|
|
648
|
-
`now` (board-local)."""
|
|
649
|
-
expected = _expected(leaves, placed, inbound, now)
|
|
665
|
+
`now` (board-local); `starts` is when the journey leaves its first stop."""
|
|
666
|
+
expected = _expected(leaves, placed, inbound, now, starts)
|
|
650
667
|
if placed is None and inbound is None:
|
|
651
668
|
status = Status.UNKNOWN
|
|
652
669
|
else:
|
|
@@ -707,14 +724,27 @@ def _along(picked: list[int], at: float) -> float | None:
|
|
|
707
724
|
return len(picked) - 1 + (at - picked[-1])
|
|
708
725
|
|
|
709
726
|
|
|
710
|
-
def inbound_words(
|
|
711
|
-
"""
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
727
|
+
def inbound_words(live: LiveDeparture, now: datetime, short: bool = False) -> str:
|
|
728
|
+
"""The bus followed in for a departure, in words, "due" counting down to
|
|
729
|
+
it getting to your stop. At the stop its journey starts: "Bus on its
|
|
730
|
+
way, due in 6 min" at the end of the journey before, then "Bus in,
|
|
731
|
+
waiting to leave". At a later stop: "Bus on its way, due in 9 min", when
|
|
732
|
+
the departure is expected there, then, in at the first stop, "Bus
|
|
733
|
+
waiting to start, due in 4 min". `short` for a board's row, which has
|
|
734
|
+
room for eighteen letters: "On its way, 6 min", "Bus in, waiting",
|
|
735
|
+
"Waiting to start". `now` is board-local without a zone, as the
|
|
736
|
+
departure's times are."""
|
|
737
|
+
inbound = live.inbound
|
|
738
|
+
if inbound is None:
|
|
739
|
+
return "No live position"
|
|
740
|
+
first = live.call_index == 0
|
|
741
|
+
if inbound.is_in and first:
|
|
716
742
|
return "Bus in, waiting" if short else "Bus in, waiting to leave"
|
|
717
|
-
minutes = int((inbound.arrives - now).total_seconds() // 60)
|
|
743
|
+
minutes = int(((inbound.arrives if first else live.expected) - now).total_seconds() // 60)
|
|
744
|
+
if inbound.is_in:
|
|
745
|
+
if short:
|
|
746
|
+
return "Waiting to start"
|
|
747
|
+
return f"Bus waiting to start, due in {minutes} min" if minutes >= 1 else "Bus waiting to start, due now"
|
|
718
748
|
if short:
|
|
719
749
|
return f"On its way, {minutes} min" if minutes >= 1 else "On its way, due"
|
|
720
750
|
return f"Bus on its way, due in {minutes} min" if minutes >= 1 else "Bus on its way, due now"
|
|
@@ -726,9 +756,7 @@ def where_words(live: LiveDeparture, found: Approach | None, now: datetime) -> s
|
|
|
726
756
|
in is (inbound_words). `found` is its approach; `now` is board-local
|
|
727
757
|
without a zone."""
|
|
728
758
|
if live.progress is None:
|
|
729
|
-
|
|
730
|
-
return inbound_words(live.inbound, now)
|
|
731
|
-
return "No live position"
|
|
759
|
+
return inbound_words(live, now)
|
|
732
760
|
if found is None:
|
|
733
761
|
return "Live position known"
|
|
734
762
|
names = tuple(stop.name for stop in found.stops)
|
|
@@ -745,11 +773,10 @@ def row_strip(live: LiveDeparture, positions: dict[str, StopPosition], now: date
|
|
|
745
773
|
if not live.live or found is None:
|
|
746
774
|
return None
|
|
747
775
|
if live.progress is None:
|
|
748
|
-
|
|
749
|
-
if inbound is None:
|
|
776
|
+
if live.inbound is None:
|
|
750
777
|
return None
|
|
751
778
|
try:
|
|
752
|
-
return Strip(inbound_words(
|
|
779
|
+
return Strip(inbound_words(live, now, short=True), len(found.stops), found.yours, None)
|
|
753
780
|
except ValueError:
|
|
754
781
|
return None
|
|
755
782
|
last = len(found.stops) - 1
|