aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-07-04 12:40:42 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-07-04 12:49:58 -0400
commitcf662b842b10c92ab525633c35af659756006306 (patch)
treec69fbc28eaba61f0c340c8160d155ba60fb507b8
parent0ac518040b42396ba509e02aa3e8c4866fac63d8 (diff)
downloadkutter-cf662b842b10c92ab525633c35af659756006306.tar.gz
kutter-cf662b842b10c92ab525633c35af659756006306.tar.xz
kutter-cf662b842b10c92ab525633c35af659756006306.zip
msgproto: Catch exceptions during identify data parsing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/msgproto.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/klippy/msgproto.py b/klippy/msgproto.py
index 9f8082cb..259271e2 100644
--- a/klippy/msgproto.py
+++ b/klippy/msgproto.py
@@ -303,18 +303,24 @@ class MessageParser:
self.messages_by_id[msgid] = msg
self.messages_by_name[msg.name] = msg
def process_identify(self, data, decompress=True):
- if decompress:
- data = zlib.decompress(data)
- self.raw_identify_data = data
- data = json.loads(data)
- messages = data.get('messages')
- commands = data.get('commands')
- responses = data.get('responses')
- self._init_messages(messages, commands+responses)
- static_strings = data.get('static_strings', {})
- self.static_strings = { int(k): v for k, v in static_strings.items() }
- self.config.update(data.get('config', {}))
- self.version = data.get('version', '')
+ try:
+ if decompress:
+ data = zlib.decompress(data)
+ self.raw_identify_data = data
+ data = json.loads(data)
+ messages = data.get('messages')
+ commands = data.get('commands')
+ responses = data.get('responses')
+ self._init_messages(messages, commands+responses)
+ static_strings = data.get('static_strings', {})
+ self.static_strings = { int(k): v for k, v in static_strings.items() }
+ self.config.update(data.get('config', {}))
+ self.version = data.get('version', '')
+ except error as e:
+ raise
+ except Exception as e:
+ logging.exception("process_identify error")
+ raise error("Error during identify: %s" % (str(e),))
def get_constant(self, name):
try:
return self.config[name]