From patchwork Fri Jul 2 21:25:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Niteesh G. S." X-Patchwork-Id: 12356535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4529AC07E95 for ; Fri, 2 Jul 2021 21:27:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C399261364 for ; Fri, 2 Jul 2021 21:27:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C399261364 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzQhI-0004NY-Vj for qemu-devel@archiver.kernel.org; Fri, 02 Jul 2021 17:27:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzQfw-0002Jl-73 for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:16 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:47077) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lzQft-0001Mw-Iz for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:16 -0400 Received: by mail-pg1-x52e.google.com with SMTP id w15so10949386pgk.13 for ; Fri, 02 Jul 2021 14:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dGTiGJOTp/bspxX8sMms2I88vB/dqPcoL0Gmp03XhO0=; b=FNrM8fnxcHlFZDoHd3nDfmNjG7sIXffHa3bVORryQ7iJTfJhKbPVdijrp5RM6O2Yno xxKk4jVmrj8a7jbrnkZHSVrq9/0Yi+atNEQnGgoebc1MdOfPHK+sJ4QgPQazrDxt2MGD mzullsEY9p0DMgN1EyHT8ocFzRPGJMq36tSu+wCv13/0tZ5vge52iIWK8iVRIbfKDgr9 o3pyxU5fI+U7RKhHY+xQ9g77mZhGrza4U0AgyLi9Xii/RGi/Okc5x/A/vHav3w94VVQW jSW26ZT3Jgt9/KH3ulEkvYvc6ENmISxNGQr2649fm9d9wNCHgXgQLZazzg0W64VxoNrW 1VwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dGTiGJOTp/bspxX8sMms2I88vB/dqPcoL0Gmp03XhO0=; b=UysmJDUUT5gbzHsoaz6PxnkVayA0TlJgMORDWMw+LWSGIm/H6Z0W6tvDFqf60lawvI rtyagi810LIaMOgEhe3es2oUBYVeWkaDSeotoglZF1j9ub3Em57wyuIMIwdkzIttxg5G CdjAF7hIHwjxbxLH1aDxYxBKJGV19gFJJYhRxFhCyLcwv/fHcxmyIOFlE2Y+XY/PXswX IUk91jVNOoMKukJbij5J4o4KkNy7GfWv8YFPdhAu/6WFZkiag1gMgJ0UBDZddBO3YsEN D9ImPO/kIUmL5E5RS1FHbCv5e97yEARbyAbeoI+lHKOesY+x858R3LYw6K2KjOWsRA1Q Do4A== X-Gm-Message-State: AOAM53032/TKTX0vDRx2ljJPctk4fo1ncech52jzifURzQscA8u8AlaC eHhH9c4/407hhMtKBoo7Wn0= X-Google-Smtp-Source: ABdhPJyHF3kITH/CXj5oynnfAA9GV9Su6vz2y7xA3CovS7HHBbUfGPZDUBVG/SL2cK24tx+mxF195A== X-Received: by 2002:a63:5015:: with SMTP id e21mr1912435pgb.272.1625261172247; Fri, 02 Jul 2021 14:26:12 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.1]) by smtp.gmail.com with ESMTPSA id o16sm71563pjw.51.2021.07.02.14.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 14:26:11 -0700 (PDT) From: G S Niteesh Babu To: jsnow@redhat.com Subject: [PATCH 1/6] python: disable pylint errors for aqmp-tui Date: Sat, 3 Jul 2021 02:55:58 +0530 Message-Id: <20210702212603.26465-2-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702212603.26465-1-niteesh.gs@gmail.com> References: <20210702212603.26465-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=niteesh.gs@gmail.com; helo=mail-pg1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: G S Niteesh Babu , Cleber Rosa , Eduardo Habkost , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Disable missing-docstring and fixme pylint warnings. This is because since the AQMP is just a prototype it is currently not documented properly and lot of todo and fixme's are still in place. Signed-off-by: G S Niteesh Babu --- python/setup.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/setup.cfg b/python/setup.cfg index bce8807702..1a552d672a 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -89,6 +89,8 @@ ignore_missing_imports = True # no Warning level messages displayed, use "--disable=all --enable=classes # --disable=W". disable=too-many-function-args, # mypy handles this with less false positives. + missing-docstring, # FIXME + fixme, # FIXME [pylint.basic] # Good variable names which should always be accepted, separated by a comma. From patchwork Fri Jul 2 21:25:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Niteesh G. S." X-Patchwork-Id: 12356539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EB7DC07E95 for ; Fri, 2 Jul 2021 21:29:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D87B261364 for ; Fri, 2 Jul 2021 21:29:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D87B261364 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzQj7-00081o-0v for qemu-devel@archiver.kernel.org; Fri, 02 Jul 2021 17:29:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzQfy-0002Kd-4G for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:19 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:41839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lzQfw-0001Ov-Dm for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:17 -0400 Received: by mail-pf1-x42d.google.com with SMTP id c5so10214649pfv.8 for ; Fri, 02 Jul 2021 14:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t+Pe/eROmqykKa9dIoKt2kOQl5E0f+1/SQgnS/Y/Hus=; b=ULKOmpJSUxzzq90maatpQU7wqD0syneuKsD0gtljOMCEqKz8wd8KOWKT8AS6kk3Eff BZF7MConSj5Jh8h2Ln6uvrtxtRCqDTvFZgGBrNrg2jTdBdqYT8tDlGgp0d2gehQgMzoq EZziRhXj4YEJtcsm4Z2X4nmWViDLcgFeqmdBfVN2S33LcGoa8XFoHMUp2iVMsvhFyyQ6 r1Pd7FvpCyQNpvwMFDisjv1puamJyUA1NBhSocZcxEvY56vJ5WBupEp/i2FDyAMi/z8l +OIHe2c9obS0o4hq75qeLpwMruiBWkTfwrROEsz4iGISrHZdCnMsK+uC2+B6gFGA9VdF sSXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t+Pe/eROmqykKa9dIoKt2kOQl5E0f+1/SQgnS/Y/Hus=; b=YMTmMnNmOpGrj+VjVzlHJnbbtlH7dC6+oA218G5TwaWRHu42M1sksWXYf7xpV+fyEV ay2Pa0pt6tkDRW+GMx7K3kG7YpuACbK5nAusOoCNn2NpFkrU5KbTMeahiIVb/m8JbdVI Jt6hAJn/le+Bf3hoxmR35nSwBMVi5PyVt+ONTenWLG2cDNJ2+Ty6ZNJsCm6b1wshLhuJ zfVmoT7G5HZFOdYIlnwWK9LVJXZHfkUsrn+hc8QN4A6kXcL6l+OkYIV9DuFV35BFzvaU TLWPpllmJVSQUZn8bMR9RfcFMSCRM/66CLI/GQP+KxUgPdniOOOlCDNTeSkL40+UMc/O JNzg== X-Gm-Message-State: AOAM530FF/dXHrin4V+/cebnFQPfxc1cVmOZwkjSAz/iw9rZpde2Fr+7 1fnhhCt5G5OF6jmixdl0Lvc= X-Google-Smtp-Source: ABdhPJyuPwelXI3CMKPzGy4hSeEKdgKEWl5831Cy56szIwNvShefO5NzjS0R4uX6Bq7YAOTZowTf3A== X-Received: by 2002:a05:6a00:17a5:b029:305:d4e8:7391 with SMTP id s37-20020a056a0017a5b0290305d4e87391mr1644790pfg.0.1625261175321; Fri, 02 Jul 2021 14:26:15 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.1]) by smtp.gmail.com with ESMTPSA id o16sm71563pjw.51.2021.07.02.14.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 14:26:15 -0700 (PDT) From: G S Niteesh Babu To: jsnow@redhat.com Subject: [PATCH 2/6] python: Add dependencies for AQMP TUI Date: Sat, 3 Jul 2021 02:55:59 +0530 Message-Id: <20210702212603.26465-3-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702212603.26465-1-niteesh.gs@gmail.com> References: <20210702212603.26465-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=niteesh.gs@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: G S Niteesh Babu , Cleber Rosa , Eduardo Habkost , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Added dependencies for the upcoming AQMP TUI under the optional 'tui' group. The same dependencies have also been added under the devel group since no work around has been found for optional groups to imply other optional groups. Signed-off-by: G S Niteesh Babu --- python/Pipfile.lock | 12 ++++++++++++ python/setup.cfg | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/python/Pipfile.lock b/python/Pipfile.lock index 8ab41a3f60..76cf1e4930 100644 --- a/python/Pipfile.lock +++ b/python/Pipfile.lock @@ -289,6 +289,18 @@ "markers": "python_version < '3.8'", "version": "==3.10.0.0" }, + "urwid": { + "hashes": [ + "sha256:588bee9c1cb208d0906a9f73c613d2bd32c3ed3702012f51efe318a3f2127eae" + ], + "version": "==2.1.2" + }, + "urwid-readline": { + "hashes": [ + "sha256:018020cbc864bb5ed87be17dc26b069eae2755cb29f3a9c569aac3bded1efaf4" + ], + "version": "==0.13" + }, "virtualenv": { "hashes": [ "sha256:14fdf849f80dbb29a4eb6caa9875d476ee2a5cf76a5f5415fa2f1606010ab467", diff --git a/python/setup.cfg b/python/setup.cfg index 1a552d672a..c62803bffc 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -44,11 +44,18 @@ devel = mypy >= 0.770 pylint >= 2.8.0 tox >= 3.18.0 + urwid >= 2.1.2 + urwid-readline >= 0.13 # Provides qom-fuse functionality fuse = fusepy >= 2.0.4 +# AQMP TUI dependencies +tui = + urwid >= 2.1.2 + urwid-readline >= 0.13 + [options.entry_points] console_scripts = qom = qemu.qmp.qom:main From patchwork Fri Jul 2 21:26:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Niteesh G. S." X-Patchwork-Id: 12356543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D651C07E95 for ; Fri, 2 Jul 2021 21:31:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD6BB613FB for ; Fri, 2 Jul 2021 21:31:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD6BB613FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzQkX-0001qS-S7 for qemu-devel@archiver.kernel.org; Fri, 02 Jul 2021 17:31:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzQg1-0002MK-WF for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:22 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:37884) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lzQfy-0001QW-K2 for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:21 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 22-20020a17090a0c16b0290164a5354ad0so10074629pjs.2 for ; Fri, 02 Jul 2021 14:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VmH3DOOEQxtLHGFhrf72YU9eXD41q84vzTs5x8dfa6I=; b=giJi4HXiJ2LwMFIFuwfL4eCvzUiu2hgQ9VYbcXlbxMhUclDch/cciCz+2kOcIgbk+4 8nzJ3fKAApC8X3LLCyxW+koheE25Gyv6Jg4qwGlyi/mpNVbu4epFDY1OuO62d74kSxw1 jxcSLZOY6u2nfkiWn1D5ajFCUj9ngpNT7+i/kbtzZqnVOipsMYSv9QPvUAEnbRklhPpn 7nRmZZo+zT1k3U9HkX/Bl9WODzHzhzyH4lMkyfVvHtvdq89zmbCfTajGdn65tSyYaonL zUkBqVP+PdJZo994xpuIC3p76zIZI+X0JI7Qny7lNDACSMfPfYyEfwLNhAAOXYmEiDNh Oqgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VmH3DOOEQxtLHGFhrf72YU9eXD41q84vzTs5x8dfa6I=; b=Jzf5C5T4rakjLex8YS4roHNJMxgX0X82acpkE+zMs3CQPAxPwuZRwMbHacZ+dL+rIB x0WR5BgO622hxBiOB8bTdGtum9/obxk7Z+c2bkJNbSimycMRUZvTe2eUz3S+scPXZWPV AvPJR052B293ztk4oYQpfLsa9qs0dJCV6glHv4xyYTxRo1ET1sQ6X2U1JaoVP6CAdK/5 VSOyjTE9iVZrmBtTZ1dk/w9LMPwFm7yc0dVodEybB8T3ttecXQlVbAxV2xLDjWPQzWjG TvKXvNk5yIkZl8qUEYTxAVy9rjPYm0oGNr8ddury9+WMdK1dhMREebt13YAil7GzKzI1 DLtg== X-Gm-Message-State: AOAM532zj7yBs5/YQL1ZSlarCSFzlE/SzpMaA2/zDPZE5S4OSQ6f7WX/ 8HYbUgUWE6/IDbKdWLJZkwQ= X-Google-Smtp-Source: ABdhPJw27S9CiO0gW64LxqoL3p5B9pLd+XasyTBUc3s1Hv7RY9P1nwr/AGCNVguckB5fLIYMd0M2Pw== X-Received: by 2002:a17:90a:49c6:: with SMTP id l6mr1568656pjm.171.1625261177429; Fri, 02 Jul 2021 14:26:17 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.1]) by smtp.gmail.com with ESMTPSA id o16sm71563pjw.51.2021.07.02.14.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 14:26:17 -0700 (PDT) From: G S Niteesh Babu To: jsnow@redhat.com Subject: [PATCH 3/6] python/aqmp-tui: Add AQMP TUI draft Date: Sat, 3 Jul 2021 02:56:00 +0530 Message-Id: <20210702212603.26465-4-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702212603.26465-1-niteesh.gs@gmail.com> References: <20210702212603.26465-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=niteesh.gs@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: G S Niteesh Babu , Cleber Rosa , Eduardo Habkost , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Added a draft of AQMP TUI. Implements the follwing basic features: 1) Command transmission/reception. 2) Shows events asynchronously. 3) Shows server status in the bottom status bar. Also added necessary pylint, mypy configurations Signed-off-by: G S Niteesh Babu --- python/qemu/aqmp/aqmp_tui.py | 246 +++++++++++++++++++++++++++++++++++ python/setup.cfg | 16 ++- 2 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 python/qemu/aqmp/aqmp_tui.py diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py new file mode 100644 index 0000000000..8e9e8ac8ff --- /dev/null +++ b/python/qemu/aqmp/aqmp_tui.py @@ -0,0 +1,246 @@ +# Copyright (c) 2021 +# +# Authors: +# Niteesh Babu G S +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +import argparse +import asyncio +import logging +import signal + +import urwid +import urwid_readline + +from .protocol import ConnectError +from .qmp_protocol import QMP, ExecInterruptedError, ExecuteError +from .util import create_task, pretty_traceback + + +UPDATE_MSG = 'UPDATE_MSG' + + +class StatusBar(urwid.Text): + """ + A simple Text widget that currently only shows connection status. + """ + def __init__(self, text=''): + super().__init__(text, align='right') + + +class Editor(urwid_readline.ReadlineEdit): + """ + Support urwid_readline features along with + history support which lacks in urwid_readline + """ + def __init__(self, master): + super().__init__(caption='> ', multiline=True) + self.master = master + self.history = [] + self.last_index = -1 + self.show_history = False + + def keypress(self, size, key): + # TODO: Add some logic for down key and clean up logic if possible. + # Returning None means the key has been handled by this widget + # which otherwise is propogated to the parent widget to be + # handled + msg = self.get_edit_text() + if key == 'up' and not msg: + # Show the history when 'up arrow' is pressed with no input text. + # NOTE: The show_history logic is necessary because in 'multiline' + # mode (which we use) 'up arrow' is used to move between lines. + self.show_history = True + last_msg = self.history[self.last_index] if self.history else '' + self.set_edit_text(last_msg) + self.edit_pos = len(last_msg) + self.last_index += 1 + elif key == 'up' and self.show_history: + if self.last_index < len(self.history): + self.set_edit_text(self.history[self.last_index]) + self.edit_pos = len(self.history[self.last_index]) + self.last_index += 1 + elif key == 'meta enter': + # When using multiline, enter inserts a new line into the editor + # send the input to the server on alt + enter + self.master.cb_send_to_server(msg) + self.history.insert(0, msg) + self.set_edit_text('') + self.last_index = 0 + self.show_history = False + else: + self.show_history = False + self.last_index = 0 + return super().keypress(size, key) + return None + + +class EditorWidget(urwid.Filler): + """ + Wraps CustomEdit + """ + def __init__(self, master): + super().__init__(Editor(master), valign='top') + + +class HistoryBox(urwid.ListBox): + """ + Shows all the QMP message transmitted/received + """ + def __init__(self, master): + self.master = master + self.history = urwid.SimpleFocusListWalker([]) + super().__init__(self.history) + + def add_to_history(self, history): + self.history.append(urwid.Text(history)) + if self.history: + self.history.set_focus(len(self.history) - 1) + + +class HistoryWindow(urwid.Frame): + """ + Composes the HistoryBox and EditorWidget + """ + def __init__(self, master): + self.master = master + self.editor = EditorWidget(master) + self.editor_widget = urwid.LineBox(self.editor) + self.history = HistoryBox(master) + self.body = urwid.Pile([('weight', 80, self.history), + ('weight', 10, self.editor_widget)]) + super().__init__(self.body) + urwid.connect_signal(self.master, UPDATE_MSG, self.cb_add_to_history) + + def cb_add_to_history(self, msg): + self.history.add_to_history(msg) + + +class Window(urwid.Frame): + """ + This is going to be the main window that is going to compose other + windows. In this stage it is unnecesssary but will be necessary in + future when we will have multiple windows and want to the switch between + them and display overlays + """ + def __init__(self, master): + self.master = master + footer = StatusBar() + body = HistoryWindow(master) + super().__init__(body, footer=footer) + + +class App(QMP): + def __init__(self, address): + urwid.register_signal(self.__class__, UPDATE_MSG) + self.window = Window(self) + self.address = address + self.aloop = asyncio.get_event_loop() + self.loop = None + super().__init__() + + # Gracefully handle SIGTERM and SIGINT signals + cancel_signals = [signal.SIGTERM, signal.SIGINT] + for sig in cancel_signals: + self.aloop.add_signal_handler(sig, self.kill_app) + + def _cb_outbound(self, msg): + urwid.emit_signal(self, UPDATE_MSG, "<-- " + str(msg)) + return msg + + def _cb_inbound(self, msg): + urwid.emit_signal(self, UPDATE_MSG, "--> " + str(msg)) + return msg + + async def wait_for_events(self): + async for event in self.events: + self.handle_event(event) + + async def _send_to_server(self, msg): + # TODO: Handle more validation errors (eg: ValueError) + try: + response = await self._raw(bytes(msg, 'utf-8')) + logging.info('Response: %s %s', response, type(response)) + except ExecuteError: + logging.info('Error response from server for msg: %s', msg) + except ExecInterruptedError: + logging.info('Error server disconnected before reply') + # FIXME: Handle this better + # Show the disconnected message in the history window + urwid.emit_signal(self, UPDATE_MSG, + '{"error": "Server disconnected before reply"}') + self.window.footer.set_text("Server disconnected") + except Exception as err: + logging.info('Exception from _send_to_server: %s', str(err)) + raise err + + def cb_send_to_server(self, msg): + create_task(self._send_to_server(msg)) + + def unhandled_input(self, key): + if key == 'esc': + self.kill_app() + + def kill_app(self): + # TODO: Work on the disconnect logic + create_task(self._kill_app()) + + async def _kill_app(self): + # It is ok to call disconnect even in disconnect state + await self.disconnect() + logging.info('disconnect finished, Exiting app') + raise urwid.ExitMainLoop() + + def handle_event(self, event): + if event['event'] == 'SHUTDOWN': + self.window.footer.set_text('Server shutdown') + + async def connect_server(self): + try: + await self.connect(self.address) + self.window.footer.set_text("Connected to {:s}".format( + f"{self.address[0]}:{self.address[1]}" + if isinstance(self.address, tuple) + else self.address + )) + except ConnectError as err: + logging.debug('Cannot connect to server %s', str(err)) + self.window.footer.set_text('Server shutdown') + + def run(self): + self.aloop.set_debug(True) + event_loop = urwid.AsyncioEventLoop(loop=self.aloop) + self.loop = urwid.MainLoop(self.window, + unhandled_input=self.unhandled_input, + handle_mouse=True, + event_loop=event_loop) + + create_task(self.wait_for_events(), self.aloop) + create_task(self.connect_server(), self.aloop) + try: + self.loop.run() + except Exception as err: + logging.error('%s\n%s\n', str(err), pretty_traceback()) + raise err + + +def main(): + parser = argparse.ArgumentParser(description='AQMP TUI') + parser.add_argument('-a', '--address', metavar='IP:PORT', required=True, + help='Address of the QMP server', dest='address') + parser.add_argument('--log', help='Address of the QMP server', + dest='log_file') + args = parser.parse_args() + + logging.basicConfig(filename=args.log_file, level=logging.DEBUG) + + address = args.address.split(':') + address[1] = int(address[1]) + + App(tuple(address)).run() + + +if __name__ == '__main__': + main() # type: ignore diff --git a/python/setup.cfg b/python/setup.cfg index c62803bffc..c6d38451eb 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -81,8 +81,22 @@ namespace_packages = True # fusepy has no type stubs: allow_subclassing_any = True +[mypy-qemu.aqmp.aqmp_tui] +disallow_untyped_defs = False +disallow_incomplete_defs = False +check_untyped_defs = False +# urwid and urwid_readline have no type stubs: +allow_subclassing_any = True + +# The following missing import directives are because these libraries do not +# provide type stubs. Allow them on an as-needed basis for mypy. [mypy-fuse] -# fusepy has no type stubs: +ignore_missing_imports = True + +[mypy-urwid] +ignore_missing_imports = True + +[mypy-urwid_readline] ignore_missing_imports = True [pylint.messages control] From patchwork Fri Jul 2 21:26:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Niteesh G. S." X-Patchwork-Id: 12356537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57460C07E95 for ; Fri, 2 Jul 2021 21:27:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD2B661364 for ; Fri, 2 Jul 2021 21:27:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD2B661364 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzQhM-0004TP-Vo for qemu-devel@archiver.kernel.org; Fri, 02 Jul 2021 17:27:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzQg2-0002Me-S2 for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:23 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:45007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lzQg1-0001R2-8o for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:22 -0400 Received: by mail-pg1-x52c.google.com with SMTP id u14so10949169pga.11 for ; Fri, 02 Jul 2021 14:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1ueaTPN7xEXakJK1s7LlaAPIYUOdKDqyBSz3qHkWlog=; b=h5x+uA/hIDs11fwBh3VHZT+udSHemkEYTKbbSO5cLGKlnzIR5tXqgx/qm1hZgabX4b /KiGrbK4bhk+/YVuA6XKtkbZPGrFNV8zs9KIPrxC2q6K1ikvK8iAQKPHd4BCyahfEgau UohpzzeZqOpMqzAeugwHmsFxz7bve/4AXdVm0h1UMuAkjmuTZjpGK09eb8XwLG/KQoUr aTROLNMSxzOiaY576s7EpUSkrLukjLe3btR6JfONiyvcXIe/y6etVmOCLXa1crQCQ3yL oaYcXVuVm86hueg0qOEPXCtmn+EusFpPsbtbRMDty94rtEhmZ4nvcOb6+GfaGPsHskTr gMWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1ueaTPN7xEXakJK1s7LlaAPIYUOdKDqyBSz3qHkWlog=; b=P9qS5zh7YpBPx2oxXce7JJSqZ/4gLBgh/IwM/SXlA1h2iYfTstyIGT+1zl4hx1QYg2 e6gwlDfzhd0LlaMU99igJ4RYhYWHYc7X0kqnCTvlK+Q4YfWc01frjCDnywx1Ba6Ex1d8 i7iT29POcLoFr+nzhBS9R8OfL1g1wgGDKwsLVjb7XSUqIVR3Vy39TmllWmyHd1kTOJBE dsJDAn4L0yDREhpVwIz/fVWjevHxfO4WV2kjYB+GuqWv1JGB6sgaEuZyDjxTfhe1duOQ gfHqsgS5SwzK5v2l9ma64UR8Prn+KHJDDRNaNLbv+8O/Pb6EXZe+YETcQe4LdLw7+OcB h8Aw== X-Gm-Message-State: AOAM5310Hnx9FsgiEfwE6xkRyBrjZ2mit0xYYUIhoBylO628RP7M3qLx 8inl22DHC41vml6Fc/8Z0SM= X-Google-Smtp-Source: ABdhPJxtqKCTgGIuCHrh8GS0S3Gu7y8DN1WWXgPEtDwllfK7W2ZvTR0gxluE7dClZgZt3mlc6rshOA== X-Received: by 2002:a05:6a00:1348:b029:30f:201d:6b76 with SMTP id k8-20020a056a001348b029030f201d6b76mr1638213pfu.55.1625261179539; Fri, 02 Jul 2021 14:26:19 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.1]) by smtp.gmail.com with ESMTPSA id o16sm71563pjw.51.2021.07.02.14.26.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 14:26:19 -0700 (PDT) From: G S Niteesh Babu To: jsnow@redhat.com Subject: [PATCH 4/6] python: add optional pygments dependency Date: Sat, 3 Jul 2021 02:56:01 +0530 Message-Id: <20210702212603.26465-5-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702212603.26465-1-niteesh.gs@gmail.com> References: <20210702212603.26465-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=niteesh.gs@gmail.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: G S Niteesh Babu , Cleber Rosa , Eduardo Habkost , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Added pygments as optional dependency for AQMP TUI. This is required for the upcoming syntax highlighting feature in AQMP TUI. The dependency has also been added in the devel optional group. Added mypy 'ignore_missing_imports' for pygments since it does not have any type stubs. Signed-off-by: G S Niteesh Babu --- python/Pipfile.lock | 8 ++++++++ python/setup.cfg | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/python/Pipfile.lock b/python/Pipfile.lock index 76cf1e4930..2c6d779348 100644 --- a/python/Pipfile.lock +++ b/python/Pipfile.lock @@ -200,6 +200,14 @@ ], "version": "==2.0.0" }, + "pygments": { + "hashes": [ + "sha256:a18f47b506a429f6f4b9df81bb02beab9ca21d0a5fee38ed15aef65f0545519f", + "sha256:d66e804411278594d764fc69ec36ec13d9ae9147193a1740cd34d272ca383b8e" + ], + "markers": "python_version >= '3.5'", + "version": "==2.9.0" + }, "pylint": { "hashes": [ "sha256:082a6d461b54f90eea49ca90fff4ee8b6e45e8029e5dbd72f6107ef84f3779c0", diff --git a/python/setup.cfg b/python/setup.cfg index c6d38451eb..4782fe5241 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -46,6 +46,7 @@ devel = tox >= 3.18.0 urwid >= 2.1.2 urwid-readline >= 0.13 + Pygments >= 2.9.0 # Provides qom-fuse functionality fuse = @@ -55,6 +56,7 @@ fuse = tui = urwid >= 2.1.2 urwid-readline >= 0.13 + Pygments >= 2.9.0 [options.entry_points] console_scripts = @@ -99,6 +101,9 @@ ignore_missing_imports = True [mypy-urwid_readline] ignore_missing_imports = True +[mypy-pygments] +ignore_missing_imports = True + [pylint.messages control] # Disable the message, report, category or checker with the given id(s). You # can either give multiple identifiers separated by comma (,) or put this From patchwork Fri Jul 2 21:26:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Niteesh G. S." X-Patchwork-Id: 12356541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3036C07E95 for ; Fri, 2 Jul 2021 21:29:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B7CB61364 for ; Fri, 2 Jul 2021 21:29:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B7CB61364 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzQj9-00087Q-N6 for qemu-devel@archiver.kernel.org; Fri, 02 Jul 2021 17:29:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzQg4-0002OR-MN for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:24 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:51968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lzQg2-0001Su-VY for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:24 -0400 Received: by mail-pj1-x1034.google.com with SMTP id n11so7270219pjo.1 for ; Fri, 02 Jul 2021 14:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pRFFZdr9At5PhIvCLVQxz2BFQzaBdzf3bf3o03wYqiI=; b=ONHZAQu+PxEGz4q5K8SDK1M7kawF5bUIVwpGpWrG7l0adOVrIK4B8lRz2JQLaUnGYt oGCyu4xZFUHKWoFV2kFQdfzTCLva5O4ZyR+NUayYfIBLGKJXFW91ffNrRCgLOidEQwpp JuA79HV13eWqu6mpR/dukERPy0RaILeBiy42eaGWqYX+7idIqmywk7BqNn6Suu5B9AcL rm1FISudotRhNNBuCFt+5Hm2VTM2X6WnUoOz9SOJt8137DLy4dUMPv1SrNddpSUKaMEC CUdNdeW9w4mpM8irECHRsFmUFB9ioesjjhkgTWtL7w8TlEdhQ03c0l9yWv3YdQWdxkOX 1cyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pRFFZdr9At5PhIvCLVQxz2BFQzaBdzf3bf3o03wYqiI=; b=bAi1uBREMBFFtvAZK3IWWFXFmFwzNiIkU86eZWxSkJEQ3hGIKBSJUEp3SRdssPPF/s ehfGTqxixn8iXvoIm1gEJhVEX9Zath4fJWrgDyU6eQNOyUovPlQzr7mmxvOqU6bfHImL b59qEWGZqzV+HDCyCVfruFwktJPdvSQ45q+KrSFuipQoRUq2sysO8CnAoDj4B2ODGt72 BtfjzfkjfpL5Bh+kzliZQWnTDyihfTpDboX8po5DjepmxVEX6erbB7aabZUl/2voRr8d BYErlBnI1lt1vT9TulFPdvDuKuK0Be9xG9MUToUYLRrXjEkfJNYJbj+LJRAf01ulGQn8 5o1A== X-Gm-Message-State: AOAM5332u2I5TM9Cn27S1DYW/PitCJC650vAYwtUkde9SfE6EFsCbcEu l2PR9PWWtwj3x8nShxTXDjw= X-Google-Smtp-Source: ABdhPJzOWpEJMgZkQN5UgncU4R6QFWbwzXIhrZlQ66DmVik7yVJ00CvlE6MMa18dt7zc/5EtY9ukPA== X-Received: by 2002:a17:902:6e02:b029:128:977c:217d with SMTP id u2-20020a1709026e02b0290128977c217dmr1485636plk.44.1625261181739; Fri, 02 Jul 2021 14:26:21 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.1]) by smtp.gmail.com with ESMTPSA id o16sm71563pjw.51.2021.07.02.14.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 14:26:21 -0700 (PDT) From: G S Niteesh Babu To: jsnow@redhat.com Subject: [PATCH 5/6] python/aqmp-tui: add syntax highlighting Date: Sat, 3 Jul 2021 02:56:02 +0530 Message-Id: <20210702212603.26465-6-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702212603.26465-1-niteesh.gs@gmail.com> References: <20210702212603.26465-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=niteesh.gs@gmail.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: G S Niteesh Babu , Cleber Rosa , Eduardo Habkost , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add syntax highlighting for the incoming and outgoing QMP messages. This is achieved using the pygments module which was added in a previous commit. The current implementation is a really simple one which doesn't allow for any configuration. In future this has to be improved to allow for easier theme config using an external config of some sort. Signed-off-by: G S Niteesh Babu --- python/qemu/aqmp/aqmp_tui.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py index 8e9e8ac8ff..03cb70a523 100644 --- a/python/qemu/aqmp/aqmp_tui.py +++ b/python/qemu/aqmp/aqmp_tui.py @@ -11,6 +11,8 @@ import logging import signal +from pygments import lexers +from pygments import token as Token import urwid import urwid_readline @@ -21,6 +23,16 @@ UPDATE_MSG = 'UPDATE_MSG' +palette = [ + (Token.Punctuation, '', '', '', 'h15,bold', 'g7'), + (Token.Text, '', '', '', '', 'g7'), + (Token.Name.Tag, '', '', '', 'bold,#f88', 'g7'), + (Token.Literal.Number.Integer, '', '', '', '#fa0', 'g7'), + (Token.Literal.String.Double, '', '', '', '#6f6', 'g7'), + (Token.Keyword.Constant, '', '', '', '#6af', 'g7'), + ('background', '', 'black', '', '', 'g7'), +] + class StatusBar(urwid.Text): """ @@ -115,7 +127,11 @@ def __init__(self, master): urwid.connect_signal(self.master, UPDATE_MSG, self.cb_add_to_history) def cb_add_to_history(self, msg): - self.history.add_to_history(msg) + formatted = [] + lexer = lexers.JsonLexer() # pylint: disable=no-member + for token in lexer.get_tokens(msg): + formatted.append(token) + self.history.add_to_history(formatted) class Window(urwid.Frame): @@ -139,6 +155,7 @@ def __init__(self, address): self.address = address self.aloop = asyncio.get_event_loop() self.loop = None + self.screen = urwid.raw_display.Screen() super().__init__() # Gracefully handle SIGTERM and SIGINT signals @@ -210,10 +227,14 @@ def handle_event(self, event): self.window.footer.set_text('Server shutdown') def run(self): + self.screen.set_terminal_properties(256) + self.aloop.set_debug(True) event_loop = urwid.AsyncioEventLoop(loop=self.aloop) - self.loop = urwid.MainLoop(self.window, + self.loop = urwid.MainLoop(urwid.AttrMap(self.window, 'background'), unhandled_input=self.unhandled_input, + screen=self.screen, + palette=palette, handle_mouse=True, event_loop=event_loop) From patchwork Fri Jul 2 21:26:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Niteesh G. S." X-Patchwork-Id: 12356545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A047BC07E95 for ; Fri, 2 Jul 2021 21:32:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3540861364 for ; Fri, 2 Jul 2021 21:32:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3540861364 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzQlo-0003U6-8t for qemu-devel@archiver.kernel.org; Fri, 02 Jul 2021 17:32:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzQg6-0002QV-Vz for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:27 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:43990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lzQg5-0001Uo-95 for qemu-devel@nongnu.org; Fri, 02 Jul 2021 17:26:26 -0400 Received: by mail-pg1-x533.google.com with SMTP id o18so10352878pgu.10 for ; Fri, 02 Jul 2021 14:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fCsZAk9ohgJJAMt1uczKgBPiMIgmfeEDdbzZxu6hJsk=; b=SzX6BGi+slZ8SuMaQpHX7b3F+ePSSk1c0CMdYmOS6aCCThKqtal4gwy/fXzFhzoup3 tG5AtQYKVXu1KAKvv7TE8p9R5dQaqmWAiBsLC3T26bq1vWLRMi8xCEM3sVrlquq2kIoK eAiaZwo++lPg/ElTubMHTY/17lWrqIUblV2OBxpdpOuZMN7H254eXQdA9aTOAppVHX7I QaRtZKtD+raArP/x1XWcfduztY8BaTVZZcBDr3BQo7cshYpmZYsgyY9DZ4Mz0MLTSikk OCl/ZvhhSZeVgEH/zXD2Ra3KY/bU9GNFCT/IuPB2Lz+cG/T1qBpSJjnEpYFYKORfTXTZ Ty0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fCsZAk9ohgJJAMt1uczKgBPiMIgmfeEDdbzZxu6hJsk=; b=g9rgEmx2M2eCjG8baSWr1bpAVwZyBhTjf/Wg1hHoRxkKjUxTX15PVoNX6Lhq4nhorB cy7LhrPH1LLBya2FMowxx3VkLJBkKr+xVgtFCkndqE3RvPTAo4MQ0vaKwyLSkGjxt5H9 F2ze4ZdVmk46iYoYxwjlhKlwpbB3PGZqLb5OVHKDfkc1nCr485sm7KMoWqkfBcLTeco2 OaQIuCU77W+s59gvCJgVBIeqS/S0rzU2PCcGbtoZ1QWWxJ6/Oo7oaYBwAlWMid1uyxNi T8ZKpWA4rFvVqVFYZxgXt+3RZgZEHra8cYmFSFVm2tUPz2hE/ep7ow9fFPmwSORYHuQo 46Zg== X-Gm-Message-State: AOAM531D3Xswtg8kQgpYj5LCklgMu8SHYzdyBumbem8z6NiI1dJx/vku mzTQ+lDMPaOCO5oU0CJ/DX0= X-Google-Smtp-Source: ABdhPJx1JpDWyOZxsyqVAsgnUeQS/p6lGfC9ybOo2/NbH8HzGT1lcqsIaBISXl2v1Lu8V3vgbttyTw== X-Received: by 2002:a63:1c0e:: with SMTP id c14mr1910902pgc.11.1625261184158; Fri, 02 Jul 2021 14:26:24 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.1]) by smtp.gmail.com with ESMTPSA id o16sm71563pjw.51.2021.07.02.14.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 14:26:23 -0700 (PDT) From: G S Niteesh Babu To: jsnow@redhat.com Subject: [PATCH 6/6] python: add entry point for aqmp-tui Date: Sat, 3 Jul 2021 02:56:03 +0530 Message-Id: <20210702212603.26465-7-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702212603.26465-1-niteesh.gs@gmail.com> References: <20210702212603.26465-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=niteesh.gs@gmail.com; helo=mail-pg1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: G S Niteesh Babu , Cleber Rosa , Eduardo Habkost , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add an entry point for aqmp-tui. This will allow it to be run from the command line using "aqmp-tui -a localhost:1234" Signed-off-by: G S Niteesh Babu --- python/setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/python/setup.cfg b/python/setup.cfg index 4782fe5241..23e30185f4 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -68,6 +68,7 @@ console_scripts = qom-fuse = qemu.qmp.qom_fuse:QOMFuse.entry_point [fuse] qemu-ga-client = qemu.qmp.qemu_ga_client:main qmp-shell = qemu.qmp.qmp_shell:main + aqmp-tui = qemu.aqmp.aqmp_tui:main [flake8] extend-ignore = E722 # Prefer pylint's bare-except checks to flake8's