Skip to content

Commit

Permalink
fix: update default handling for yes/no questions (#2357)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvinSchiller authored Apr 26, 2024
1 parent 8069179 commit 1fb7a84
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
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':
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

0 comments on commit 1fb7a84

Please sign in to comment.