1
0
forked from drath/libratbag

tools: print a nice error when we don't have the required capabilities

Fixes #583

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2018-12-19 12:08:06 +10:00
committed by Benjamin Tissoires
parent 1586913fc7
commit 16e052d846
2 changed files with 12 additions and 5 deletions

View File

@@ -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:

View File

@@ -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__":