From 16e052d8465fcfe77ebc26f9354bcd6de8e5cafd Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 19 Dec 2018 12:08:06 +1000 Subject: [PATCH] tools: print a nice error when we don't have the required capabilities Fixes #583 Signed-off-by: Peter Hutterer --- tools/ratbagctl.devel.in | 12 ++++++++---- tools/ratbagctl.in | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/ratbagctl.devel.in b/tools/ratbagctl.devel.in index 549cdb10..189a9cd6 100755 --- a/tools/ratbagctl.devel.in +++ b/tools/ratbagctl.devel.in @@ -30,6 +30,7 @@ import time import toolbox import signal import sys +from ratbagctl import RatbagErrorCapability # NOQA def main(argv): @@ -64,10 +65,13 @@ def main(argv): parser.print_help() return else: - f(ratbagd, cmd) - # give time for ratbagd to receive async requests before - # we try to terminate it - time.sleep(0.5) + try: + f(ratbagd, cmd) + # give time for ratbagd to receive async requests before + # we try to terminate it + time.sleep(0.5) + except RatbagErrorCapability as e: + print("Error: {}".format(e), file=sys.stderr) finally: try: if cmd.keepalive: diff --git a/tools/ratbagctl.in b/tools/ratbagctl.in index 6608426a..ebb2402c 100755 --- a/tools/ratbagctl.in +++ b/tools/ratbagctl.in @@ -1562,7 +1562,10 @@ def main(argv): parser.print_help() return else: - f(r, cmd) + try: + f(r, cmd) + except RatbagErrorCapability as e: + print("Error: {}".format(e), file=sys.stderr) if __name__ == "__main__":