From d40f66a40998d3291fd9c31bdce159be5d1bf95e Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 3 Mar 2021 11:20:35 -0800 Subject: [PATCH] Updated scripts to use new shell functions --- adafruit_fanservice.py | 8 +------- i2smic.py | 7 +------ joy-bonnet.py | 7 +------ raspi-blinka.py | 9 ++------- rpi_pin_kernel_firmware.py | 1 + 5 files changed, 6 insertions(+), 26 deletions(-) diff --git a/adafruit_fanservice.py b/adafruit_fanservice.py index a8a892f..c8b1139 100644 --- a/adafruit_fanservice.py +++ b/adafruit_fanservice.py @@ -51,13 +51,7 @@ Run time < 1 minute. Reboot not required.""") shell.info('Enabling Raspberry Pi Fan Service on GPIO 4') shell.run_command("sudo raspi-config nonint do_fan 0 4") shell.info('Done!') - if not shell.prompt("REBOOT NOW?", default="y"): - print("Exiting without reboot.") - shell.exit() - print("Reboot started...") - os.sync() - shell.reboot() - shell.exit() + shell.prompt_reboot() else: shell.info('Adding adafruit_fan.service') contents = """[Unit] diff --git a/i2smic.py b/i2smic.py index 8f4d93f..eddca57 100644 --- a/i2smic.py +++ b/i2smic.py @@ -59,12 +59,7 @@ Installing...""") Settings take effect on next boot. """) - if not shell.prompt("REBOOT NOW?", default="n"): - print("Exiting without reboot.") - shell.exit() - print("Reboot started...") - shell.reboot() - shell.exit() + shell.prompt_reboot() # Main function if __name__ == "__main__": diff --git a/joy-bonnet.py b/joy-bonnet.py index fe59c88..5aa145e 100755 --- a/joy-bonnet.py +++ b/joy-bonnet.py @@ -106,12 +106,7 @@ Updating package index files...""") Settings take effect on next boot. """) - if not shell.prompt("REBOOT NOW?", default="n"): - print("Exiting without reboot.") - shell.exit() - print("Reboot started...") - shell.reboot() - shell.exit() + shell.prompt_reboot() # Main function if __name__ == "__main__": diff --git a/raspi-blinka.py b/raspi-blinka.py index 746a147..002f12b 100644 --- a/raspi-blinka.py +++ b/raspi-blinka.py @@ -78,6 +78,7 @@ Raspberry Pi and installs Blinka shell.bail("Sorry. This script currently only runs on Raspberry Pi OS.") if not shell.is_python3(): shell.bail("You must be running Python 3. Older versions have now been deprecated.") + shell.check_kernel_update_reboot_required() if default_python_version() < 3: shell.warn("WARNING Default System python version is {}. It will be updated to Version 3.".format(default_python_version(False))) default_python = 2 @@ -94,13 +95,7 @@ Raspberry Pi and installs Blinka Settings take effect on next boot. """) - if not shell.prompt("REBOOT NOW?", default="y"): - print("Exiting without reboot.") - shell.exit() - print("Reboot started...") - os.sync() - shell.reboot() - shell.exit() + shell.prompt_reboot() # Main function if __name__ == "__main__": diff --git a/rpi_pin_kernel_firmware.py b/rpi_pin_kernel_firmware.py index 92329d2..43935b8 100644 --- a/rpi_pin_kernel_firmware.py +++ b/rpi_pin_kernel_firmware.py @@ -52,6 +52,7 @@ Pin: version {} Pin-Priority:999 """.format(package, version)) + shell.prompt_reboot() # Main function if __name__ == "__main__":