Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default handling for yes/no questions #2357

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions components/audio/PirateAudioHAT/setup_pirateAudioHAT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ source "${JUKEBOX_HOME_DIR}"/scripts/helperscripts/inc.systemHelper.sh

question() {
local question=$1
read -p "${question} (y/n)? " choice
read -p "${question} (Y/n)? " choice
case "$choice" in
y|Y ) ;;
n|N ) exit 0;;
* ) echo "Error: invalid" ; question ${question};;
[nN][oO]|[nN]) exit 0;;
* ) ;;
esac
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ BUTTONS_USB_ENCODER_DIR="${JUKEBOX_HOME_DIR}/components/controls/buttons_usb_enc

question() {
local question=$1
read -p "${question} (y/n)? " choice
read -p "${question} (Y/n)? " choice
case "$choice" in
y|Y ) ;;
n|N ) exit 0;;
* ) echo "Error: invalid" ; question ${question};;
[nN][oO]|[nN]) exit 0;;
* ) ;;
esac
}

Expand Down
7 changes: 3 additions & 4 deletions components/rfid-reader/PN532/setup_pn532.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ JUKEBOX_HOME_DIR="${HOME_DIR}/RPi-Jukebox-RFID"

question() {
local question=$1
read -p "${question} (y/n)? " choice
read -p "${question} (Y/n)? " choice
case "$choice" in
y|Y ) ;;
n|N ) exit 0;;
* ) echo "Error: invalid" ; question ${question};;
[nN][oO]|[nN]) exit 0;;
* ) ;;
esac
}

Expand Down
7 changes: 3 additions & 4 deletions components/rfid-reader/RC522/setup_rc522.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ JUKEBOX_HOME_DIR="${HOME_DIR}/RPi-Jukebox-RFID"

question() {
local question=$1
read -p "${question} (y/n)? " choice
read -p "${question} (Y/n)? " choice
case "$choice" in
y|Y ) ;;
n|N ) exit 0;;
* ) echo "Error: invalid" ; question ${question};;
[nN][oO]|[nN]) exit 0;;
* ) ;;
esac
}

Expand Down
6 changes: 3 additions & 3 deletions scripts/RegisterDevice.py.Multi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def runCmd(cmd, wait=True):
def setupPN532():
answer = input('Please make sure that the PN532 reader is wired up correctly '
'to the GPIO ports before continuing...\n Continue?: [Y/n]')
if not answer or answer[0] != 'Y':
if answer and answer[0].lower() == 'n':
s-martin marked this conversation as resolved.
Show resolved Hide resolved
return False
print("Activating I2C interface...\n")
runCmd("sudo raspi-config nonint do_i2c 0")
Expand All @@ -41,7 +41,7 @@ def setupPN532():
def setupMFRC522():
answer = input('Please make sure that the RC522 reader is wired up correctly '
'to the GPIO ports before continuing...\n Continue?: [Y/n]')
if not answer or answer[0] != 'Y':
if answer and answer[0].lower() == 'n':
return False
print("Installing Python requirements for RC522...\n")
runCmd("sudo python3 -m pip install --upgrade --force-reinstall "
Expand Down Expand Up @@ -78,7 +78,7 @@ def configureDevices():
addDevice()
while True:
answer = input('Do you want to add another device: [Y/n]')
if not answer or answer[0] != 'Y':
if answer and answer[0].lower() == 'n':
break
addDevice()

Expand Down