Merge pull request #15 from makermelissa/main

Update with buster and allow arguments for prompt_reboot
This commit is contained in:
Melissa LeBlanc-Williams 2022-11-09 08:18:10 -08:00 committed by GitHub
commit c6581122fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -145,13 +145,13 @@ class Shell:
colorize = getattr(colored, color)
print(colorize(message))
def prompt(self, message, *, default=None, force_arg=None):
def prompt(self, message, *, default=None, force_arg=None, force_arg_value=True):
"""
A Yes/No prompt that accepts optional defaults
Returns True for Yes and False for No
"""
if force_arg is not None and self.argument_exists(force_arg):
return True
return force_arg_value
if default is None:
choicebox = "[y/n]"
else:
@ -491,7 +491,7 @@ class Shell:
"""Return a string containing the raspbian version"""
if self.get_os() != "Raspbian":
return None
raspbian_releases = ("buster", "stretch", "jessie", "wheezy")
raspbian_releases = ("bullseye", "buster", "stretch", "jessie", "wheezy")
if os.path.exists("/etc/os-release"):
with open("/etc/os-release", encoding="utf-8") as f:
release_file = f.read()
@ -502,9 +502,9 @@ class Shell:
return raspbian
return None
def prompt_reboot(self):
def prompt_reboot(self, default="y", **kwargs):
"""Prompt the user for a reboot"""
if not self.prompt("REBOOT NOW?", default="y"):
if not self.prompt("REBOOT NOW?", default=default, **kwargs):
print("Exiting without reboot.")
else:
print("Reboot started...")