From 26cc2c7138edc6de5a0544f25895bcb3fa1f257d Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Wed, 1 Mar 2023 03:59:19 +0300 Subject: [PATCH] ratbagctl: check if there is an active profile --- tools/ratbagctl.in.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/ratbagctl.in.in b/tools/ratbagctl.in.in index c95ed17a..d03c6f95 100755 --- a/tools/ratbagctl.in.in +++ b/tools/ratbagctl.in.in @@ -82,6 +82,9 @@ def find_profile(r, args): sys.exit(1) except AttributeError: p = d.active_profile + if r is None: + print("The device has no active profile") + sys.exit(1) return p, d @@ -530,7 +533,11 @@ def func_profile_name_set(r, args): def func_profile_active_get(r, args): d = find_device(r, args) - print(d.active_profile.index) + profile = d.active_profile + if profile is None: + print("The device has no active profile") + sys.exit(1) + print(profile.index) def func_profile_active_set(r, args):