def cmd_post_rgb_change_single(self, req, resp, post_params):
"""This method handles changing the keys of the keyboard to a single colour."""
# We check if all arguments exist
if post_params["arguments"]["key"] and post_params["arguments"]["color"]:
if self.is_hex_color(post_params["arguments"]["color"]):
# We check if the command executed successfully
if self.keyboard.set_key_color(post_params["arguments"]["key"], (
int(post_params["arguments"]["color"][:2], base=16),
int(post_params["arguments"]["color"][2:4], base=16),
int(post_params["arguments"]["color"][4:], base=16))):
# Successfully executed the command
resp.status = falcon.HTTP_200
resp.body = json.dumps({"message": "Command successfully executed"})
return
else:
# Invalid arguments
resp.status = falcon.HTTP_400
resp.body = json.dumps({"message": "Invalid arguments"})
else:
# Invalid arguments
resp.status = falcon.HTTP_400
resp.body = json.dumps({"message": "Invalid arguments"})
else:
# Invalid arguments
resp.status = falcon.HTTP_400
resp.body = json.dumps({"message": "Invalid arguments"})
评论列表
文章目录