Refactor message hooking
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import traceback
|
||||
from ast import Try
|
||||
|
||||
import flask
|
||||
|
||||
from octoprint_CalibrationTools import EStepsApi, PIDAutoTune
|
||||
@@ -33,7 +36,13 @@ class API(EStepsApi.API, PIDAutoTune.API):
|
||||
)
|
||||
|
||||
def on_api_command(self, command, data):
|
||||
self._logger.debug("API command [%s] received payload [%s]", command, data)
|
||||
for key, api in self.commandsRegistration.items():
|
||||
if command in api["commands"]:
|
||||
return api["cls"].apiGateWay(self, command, data)
|
||||
try:
|
||||
self._logger.debug("API command [%s] received payload [%s]", command, data)
|
||||
for key, api in self.commandsRegistration.items():
|
||||
if command in api["commands"]:
|
||||
return api["cls"].apiGateWay(self, command, data)
|
||||
except Exception as e:
|
||||
self._logger.error(traceback.format_exc())
|
||||
return flask.abort(500, {
|
||||
"msg": "An error curred"
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user