Gate raspi-config calls behind Shell.run_raspi_config() (fixes #321)#384
Merged
makermelissa merged 1 commit intoMay 25, 2026
Conversation
Contributor
Author
|
Follow-up: I've also opened adafruit/Adafruit_Python_Shell#38 which adds the same gating logic as a reusable Once that lands and is released to PyPI, the local Happy to do this either way:
Let me know which you'd prefer. |
…it#321) This repo's Python installer scripts shell out to 'raspi-config nonint ...' for SPI/I2C toggles, overscan, boot behaviour, fan service, etc. The raspi-config binary is only shipped (and only honored) on Raspberry Pi OS; on DietPi, Ubuntu, and other Debian-based distros the binary is absent and shell.run_command() returns falsy on the missing executable, so the tweak silently doesn't happen and the user sees a confusing 'command not found' line mid-install. Adafruit_Python_Shell now ships Shell.run_raspi_config(args, ...) (adafruit/Adafruit_Python_Shell#38) which gates on shell.is_raspberry_pi_os() and short-circuits cleanly on non-Pi-OS hosts, returning True (or '' when return_output=True so .strip() callers stay happy). Migrate every raspi-config nonint call site in the repo's Python scripts to the new helper: * adafruit-pitft.py (6 sites: boot_behaviour, boot_splash, boot_target, overscan x2) * raspi-blinka.py (7 sites: i2c, spi, serial_hw, serial, ssh, camera, disable_raspi_config_at_boot) * raspi-spi-reassign.py (3 sites incl. get_spi with return_output=True / .strip()) * joy-bonnet.py (2 sites: i2c, overscan) * retrogame.py (1 site: i2c) * pitft-fbcp.py (1 site: spi) * rtc.py (1 site: i2c) * adafruit_fanservice.py (1 site: fan -- previously gated only on is_raspberry_pi(), which is true on DietPi-on-Pi-hardware) Closes the underlying 'non-Pi-OS distro support' gap reported in adafruit#321. (The reporter's specific is_wayland()/loginctl complaint was already fixed in d14339d, but the broader raspi-config-unavailable problem on the same distro remained.) Behavior on Raspberry Pi OS is unchanged. The leading 'sudo' on the old run_command lines is dropped: all of these installers already require root via require_root() (or equivalent), so the inner sudo was redundant. Bash-only scripts in this repo (pi-eyes.sh, arcade-bonnet.sh, rgb-matrix.sh, retrogame.sh, spectro.sh) call raspi-config directly and are out of scope here.
56c8633 to
053a85a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Python installer scripts in this repo shell out to
raspi-config nonint ...to toggle SPI/I2C, set overscan, change boot behaviour, configure the fan service, etc.raspi-configis only shipped (and only honored) on Raspberry Pi OS — on DietPi, Ubuntu, and other Debian-based distros the binary is absent andshell.run_commandreturns falsy on the missing executable, so the tweak silently doesn't happen and the user sees a confusingcommand not foundline mid-install. That's the underlying "non-Pi-OS distro" gap behind #321; the reporter's specificis_wayland()/loginctlcomplaint was already fixed when that helper was deleted in d14339d, but the broader raspi-config-unavailable problem on the same distro remained.Approach
adafruit/Adafruit_Python_Shell#38 (now merged + released) added a reusable
Shell.run_raspi_config(args, suppress_message=False, return_output=False, run_as_user=None)that gates onis_raspberry_pi_os()and short-circuits to a no-op on non-Pi-OS hosts (returningTrue, or""whenreturn_output=Trueso.strip()callers stay happy).This PR migrates every
raspi-config nonintcall site in the repo's Python installers to use it.adafruit-pitft.pydo_boot_behaviour,do_boot_splash,do_boot_target,do_overscan×2raspi-blinka.pydo_i2c,do_spi,do_serial_hw,do_serial,do_ssh,do_camera,disable_raspi_config_at_bootraspi-spi-reassign.pydo_spi×2 +get_spi(usesreturn_output=True+.strip())joy-bonnet.pydo_i2c,do_overscanretrogame.pydo_i2cpitft-fbcp.pydo_spirtc.pydo_i2cadafruit_fanservice.pydo_fan— was previously gated only onis_raspberry_pi(), which is true on DietPi-on-Pi-hardwareTotal: 22 call sites across 8 files, +22 / −22 net.
The leading
sudoon the oldrun_commandlines is dropped: all of these installers already require root (require_root()or equivalent), so the inner sudo was redundant.Out of scope
Bash-only scripts in this repo (
pi-eyes.sh,arcade-bonnet.sh,rgb-matrix.sh,retrogame.sh,spectro.sh) still callraspi-configdirectly. They don't useadafruit_shelland would need a different fix; happy to follow up separately if you want that too.Test plan
ast.parse) clean across all 8 files (pre-existingSyntaxWarnings on invalid escape sequences are unrelated).astwalk that all 22 migrated call sites resolve to syntactically validshell.run_raspi_config(...)invocations, withsuppress_message/return_outputkwargs preserved on the three sites that use them.Shell.run_commandmonkey-patched to record calls:run_raspi_config("do_overscan 1")forwards torun_command("raspi-config nonint do_overscan 1", ...)exactly as before.is_raspberry_pi_ospatched toFalse): all calls short-circuit, return truthy / empty string, zerorun_commandinvocations.References