keyboard.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:ckb-water-vapor 作者: Drummersbrother 项目源码 文件源码
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"})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号