tools: ratbagctl.devel: fix exception if the given arguments are wrong

"sudo ./build/ratbagctl.devel profile 2 4" returns an exception with cmd
being unknown.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
Benjamin Tissoires
2017-08-22 13:39:49 +02:00
committed by Peter Hutterer
parent 87ecd6e252
commit b2d29a0285

View File

@@ -45,6 +45,8 @@ def main(argv):
parser.want_keepalive = True
print('export RATBAGCTL_DEVEL="{}"\n'.format(os.environ['RATBAGCTL_DEVEL']))
cmd = None
try:
cmd = parser.parse(argv)
cmd.func(ratbagd, cmd)
@@ -54,6 +56,8 @@ def main(argv):
signal.pause()
except KeyboardInterrupt:
pass
except AttributeError: # in case the parsing failed and cmd is None
pass
toolbox.terminate_ratbagd(ratbagd_process)