本文整理汇总了Python中commands.Commands.execute_cmd方法的典型用法代码示例。如果您正苦于以下问题:Python Commands.execute_cmd方法的具体用法?Python Commands.execute_cmd怎么用?Python Commands.execute_cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类commands.Commands
的用法示例。
在下文中一共展示了Commands.execute_cmd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onMessage
# 需要导入模块: from commands import Commands [as 别名]
# 或者: from commands.Commands import execute_cmd [as 别名]
def onMessage(self, payload, isBinary):
"""
Called whenever a new message is sent by an authenticated client.
"""
if isBinary:
print("Binary message received: {0} bytes".format(len(payload)))
return
# validate received command
try:
received_cmd = payload.decode('utf8')
cmd, value, external = Commands.validate_cmd(received_cmd)
except Exception as error:
self.factory.broadcast(str(error))
return
if external is True:
# hand valid cmd to arduino
Commands.request_cmd(cmd, value)
else:
# hand valid cmd to linuino
result = Commands.execute_cmd(cmd, value)
self.factory.broadcast(result)