Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
yatch committed Jun 3, 2019
1 parent 00f8c8f commit f522b6b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions otbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,14 @@ def _on_mqtt_connect(self, client, userdata, flags, rc):
self.tb.on_mqtt_connect()

# discover motes
self._excecute_command_safely('box', 'all', json.dumps({'token': 123}), 'discovermotes')
self._execute_command_safely('box', 'all', json.dumps({'token': 123}), 'discovermotes')

def _on_mqtt_message(self, client, userdata, message):

# call the handler
self._excecute_commands(message.topic, message.payload)
self._execute_commands(message.topic, message.payload)

def _excecute_commands(self, topic, payload):
def _execute_commands(self, topic, payload):
# parse the topic to extract deviceType, deviceId and cmd ([0-9\-]+)
try:
m = re.search('{0}/deviceType/([a-z]+)/deviceId/([\w,\-]+)/cmd/([a-z]+)'.format(self.testbed), topic)
Expand Down Expand Up @@ -336,15 +336,15 @@ def _excecute_commands(self, topic, payload):
for d in device_to_comand:
commands_handlers += [threading.Thread(
name = '{0}_command_{1}'.format(d, cmd),
target = self._excecute_command_safely,
target = self._execute_command_safely,
args = (deviceType, d, payload, cmd))
]
for handler in commands_handlers:
handler.start()
except:
self.logger.exception("Could not parse command with topic %s", topic)

def _excecute_command_safely(self, deviceType, deviceId, payload, cmd):
def _execute_command_safely(self, deviceType, deviceId, payload, cmd):
'''
Executes the handler of a command in a try/except environment so exception doesn't crash server.
'''
Expand Down

0 comments on commit f522b6b

Please sign in to comment.