From 16de1417867cd6b4a5123c654bbe7d2a8b9522fb Mon Sep 17 00:00:00 2001 From: Bea Steers Date: Thu, 27 May 2021 14:10:11 -0400 Subject: [PATCH 1/3] make i2smic noninteractive --- i2smic.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/i2smic.py b/i2smic.py index b6cc63c..d2580a8 100644 --- a/i2smic.py +++ b/i2smic.py @@ -1,3 +1,4 @@ +import os try: from adafruit_shell import Shell except ImportError: @@ -23,7 +24,9 @@ I2S microphone support. else: shell.bail("Unsupported Pi board detected.") - auto_load = shell.prompt("Auto load module at boot?") + auto_load = ( + not shell.argument_exists('noautoload') and + shell.prompt("Auto load module at boot?", force_arg="autoload")) print(""" Installing...""") @@ -59,7 +62,19 @@ Installing...""") Settings take effect on next boot. """) - shell.prompt_reboot() + + # NOTE: shell.prompt_reboot() doesn't support force_arg or noreboot + should_reboot = ( + not shell.argument_exists('noreboot') and + shell.prompt("REBOOT NOW?", default="y", force_arg="reboot")) + + if should_reboot: + print("Reboot started...") + os.sync() # from Shell.prompt_reboot + shell.reboot() + else: + print("Exiting without reboot.") + shell.exit() # Main function if __name__ == "__main__": From bc463b10995a5acda0d852d09b9843c109cb6970 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 9 Nov 2022 10:31:57 -0800 Subject: [PATCH 2/3] Simplified code --- i2smic.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/i2smic.py b/i2smic.py index 8c5b9c0..d043672 100644 --- a/i2smic.py +++ b/i2smic.py @@ -25,7 +25,7 @@ I2S microphone support. shell.bail("Unsupported Pi board detected.") auto_load = ( - not shell.argument_exists('noautoload') and + not shell.argument_exists('noautoload') and shell.prompt("Auto load module at boot?", force_arg="autoload")) print(""" @@ -62,19 +62,8 @@ Installing...""") Settings take effect on next boot. """) - - # NOTE: shell.prompt_reboot() doesn't support force_arg or noreboot - should_reboot = ( - not shell.argument_exists('noreboot') and - shell.prompt("REBOOT NOW?", default="y", force_arg="reboot")) - - if should_reboot: - print("Reboot started...") - os.sync() # from Shell.prompt_reboot - shell.reboot() - else: - print("Exiting without reboot.") - shell.exit() + if not shell.argument_exists('noreboot'): + shell.prompt_reboot(force_arg="reboot") # Main function if __name__ == "__main__": From 08283cf58ab0ae0da14f11584b5f6739a273b8ac Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 9 Nov 2022 10:32:56 -0800 Subject: [PATCH 3/3] Remove unused import os --- i2smic.py | 1 - 1 file changed, 1 deletion(-) diff --git a/i2smic.py b/i2smic.py index d043672..b8a71f8 100644 --- a/i2smic.py +++ b/i2smic.py @@ -1,4 +1,3 @@ -import os try: from adafruit_shell import Shell except ImportError: