dbus: fix timeout error if the index is invalid

If the index is not valid, a python exception was raised, and the dbus
message was left without and answer.

Coincidentally, this matches the documentation
pull/14/head
Benjamin Tissoires 2018-01-19 17:42:11 +01:00 committed by Peter Hutterer
parent 1b73de68b2
commit f6d09d7086
1 changed files with 6 additions and 1 deletions

View File

@ -159,7 +159,12 @@ class TuhiDBusDevice(GObject.Object):
def _json_data(self, args):
index = args[0]
return self.drawings[index].json()
try:
drawing = self.drawings[index]
except IndexError:
return ''
else:
return drawing.json()
def add_drawing(self, drawing):
self.drawings.append(drawing)