更新重启到 BIOS 为 UEFI,优化获取型号和版本的错误处理逻辑

This commit is contained in:
Ing 2025-01-13 15:21:14 +08:00
parent 4119344e60
commit 9c636e8390
19 changed files with 5554 additions and 5552 deletions

View File

@ -145,7 +145,8 @@ def getmodels(platforms=None):
models.sort(key=lambda k: (k["arch"], k["name"])) models.sort(key=lambda k: (k["arch"], k["name"]))
except Exception as e: except Exception as e:
click.echo(f"Error: {e}") # click.echo(f"Error: {e}")
pass
print(json.dumps(models, indent=4)) print(json.dumps(models, indent=4))
@ -190,7 +191,8 @@ def getmodelsbykb(platforms=None):
continue continue
models.append({"name": d[0].split("<br")[0], "arch": d[5].lower()}) models.append({"name": d[0].split("<br")[0], "arch": d[5].lower()})
except Exception as e: except Exception as e:
click.echo(f"Error: {e}") # click.echo(f"Error: {e}")
pass
models.sort(key=lambda x: (x["arch"], x["name"])) models.sort(key=lambda x: (x["arch"], x["name"]))
print(json.dumps(models, indent=4)) print(json.dumps(models, indent=4))
@ -272,7 +274,8 @@ def getpats4mv(model, version):
'sum': S['files'][0]['checksum'] 'sum': S['files'][0]['checksum']
} }
except Exception as e: except Exception as e:
click.echo(f"Error: {e}") # click.echo(f"Error: {e}")
pass
pats = {k: pats[k] for k in sorted(pats.keys(), reverse=True)} pats = {k: pats[k] for k in sorted(pats.keys(), reverse=True)}
print(json.dumps(pats, indent=4)) print(json.dumps(pats, indent=4))
@ -321,7 +324,8 @@ def getpats(models=None):
pats[model] = {} pats[model] = {}
pats[model][__fullversion(ver)] = item.attrs['href'] pats[model][__fullversion(ver)] = item.attrs['href']
except Exception as e: except Exception as e:
click.echo(f"Error: {e}") # click.echo(f"Error: {e}")
pass
print(json.dumps(pats, indent=4)) print(json.dumps(pats, indent=4))

View File

@ -397,7 +397,7 @@ function checkBIOS_VT_d() {
# Rebooting # Rebooting
# 1 - mode # 1 - mode
function rebootTo() { function rebootTo() {
local MODES="config recovery junior bios memtest" local MODES="config recovery junior uefi memtest"
if [ -z "${1}" ] || ! echo "${MODES}" | grep -wq "${1}"; then exit 1; fi if [ -z "${1}" ] || ! echo "${MODES}" | grep -wq "${1}"; then exit 1; fi
# echo "Rebooting to ${1} mode" # echo "Rebooting to ${1} mode"
GRUBPATH="$(dirname "$(find "${PART1_PATH}/" -name grub.cfg 2>/dev/null | head -1)")" GRUBPATH="$(dirname "$(find "${PART1_PATH}/" -name grub.cfg 2>/dev/null | head -1)")"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -126,7 +126,7 @@ function modelMenu() {
PS="$(readConfigEntriesArray "platforms" "${WORK_PATH}/platforms.yml" | sort)" PS="$(readConfigEntriesArray "platforms" "${WORK_PATH}/platforms.yml" | sort)"
MJ="$(python3 ${WORK_PATH}/include/functions.py getmodels -p "${PS[*]}")" MJ="$(python3 ${WORK_PATH}/include/functions.py getmodels -p "${PS[*]}")"
if [ "${MJ:-[]}" = "[]" ]; then if [ "${MJ:-"[]"}" = "[]" ]; then
DIALOG --title "$(TEXT "Model")" \ DIALOG --title "$(TEXT "Model")" \
--msgbox "$(TEXT "Unable to connect to Synology website, Please check the network and try again, or use 'Parse Pat'!")" 0 0 --msgbox "$(TEXT "Unable to connect to Synology website, Please check the network and try again, or use 'Parse Pat'!")" 0 0
return 1 return 1
@ -257,7 +257,7 @@ function productversMenu() {
--infobox "$(TEXT "Get pat data ...")" 0 0 --infobox "$(TEXT "Get pat data ...")" 0 0
fi fi
PJ="$(python3 ${WORK_PATH}/include/functions.py getpats4mv -m "${MODEL}" -v "${selver}")" PJ="$(python3 ${WORK_PATH}/include/functions.py getpats4mv -m "${MODEL}" -v "${selver}")"
if [ "${PJ:-{}}" = "{}" ]; then if [ "${PJ:-"{}"}" = "{}" ]; then
if [ -z "${1}" ]; then if [ -z "${1}" ]; then
MSG="$(TEXT "Unable to connect to Synology website, Please check the network and try again, or use 'Parse Pat'!")" MSG="$(TEXT "Unable to connect to Synology website, Please check the network and try again, or use 'Parse Pat'!")"
DIALOG --title "$(TEXT "Addons")" \ DIALOG --title "$(TEXT "Addons")" \
@ -4125,9 +4125,9 @@ else
echo "x \"$(TEXT "Reboot to RR")\"" echo "x \"$(TEXT "Reboot to RR")\""
echo "y \"$(TEXT "Reboot to Recovery")\"" echo "y \"$(TEXT "Reboot to Recovery")\""
echo "z \"$(TEXT "Reboot to Junior")\"" echo "z \"$(TEXT "Reboot to Junior")\""
#if efibootmgr | grep -q "^Boot0000"; then if [ -d "/sys/firmware/efi" ]; then
echo "b \"$(TEXT "Reboot to BIOS")\"" echo "b \"$(TEXT "Reboot to UEFI")\""
#fi fi
echo "s \"$(TEXT "Back to shell")\"" echo "s \"$(TEXT "Back to shell")\""
echo "e \"$(TEXT "Exit")\"" echo "e \"$(TEXT "Exit")\""
} >"${TMP_PATH}/menu" } >"${TMP_PATH}/menu"
@ -4168,10 +4168,8 @@ else
;; ;;
b) b)
DIALOG --title "$(TEXT "Main menu")" \ DIALOG --title "$(TEXT "Main menu")" \
--infobox "$(TEXT "Reboot to BIOS")" 0 0 --infobox "$(TEXT "Reboot to UEFI")" 0 0
#efibootmgr -n 0000 >/dev/null 2>&1 rebootTo uefi
#reboot
rebootTo bios
exit 0 exit 0
;; ;;
s) s)