Improve error checking in listing users
This commit is contained in:
@ -41,7 +41,7 @@ def run_cmd(command: list[str]):
|
||||
Runs a command and returns the output.
|
||||
Could raise subprocess.CalledProcessError
|
||||
'''
|
||||
if DEBUG and Command.GET_USER.value not in command:
|
||||
if DEBUG and Command.GET_USER.value not in command and Command.LIST_USERS.value not in command:
|
||||
print(' '.join(command))
|
||||
result = subprocess.check_output(command, shell=False)
|
||||
if DEBUG:
|
||||
|
||||
6
menu.sh
6
menu.sh
@ -143,7 +143,11 @@ hysteria2_get_user_handler() {
|
||||
}
|
||||
|
||||
hysteria2_list_users_handler() {
|
||||
users_json=$(python3 $CLI_PATH list-users)
|
||||
users_json=$(python3 $CLI_PATH list-users 2>/dev/null)
|
||||
if [ $? -ne 0 ] || [ -z "$users_json" ]; then
|
||||
echo -e "\033[0;31mError:\033[0m Failed to list users."
|
||||
return 1
|
||||
fi
|
||||
users_array=($(echo "$users_json" | jq -r '.[] | .username'))
|
||||
|
||||
if [[ ${#users_array[@]} -eq 0 ]]; then
|
||||
|
||||
Reference in New Issue
Block a user