From patchwork Tue Jul 13 22:07:29 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: 1504898 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=sjqKedvh; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GPZXl5zWbz9sX1 for ; Wed, 14 Jul 2021 08:08:54 +1000 (AEST) Received: from localhost ([::1]:52702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3QaB-0001EB-G7 for incoming@patchwork.ozlabs.org; Tue, 13 Jul 2021 18:08:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3QZ5-0001Cf-TT for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:43 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:40757) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3QZ4-00063l-Jx for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:43 -0400 Received: by mail-pf1-x430.google.com with SMTP id j199so47402pfd.7 for ; Tue, 13 Jul 2021 15:07:42 -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=sjqKedvhKjF95ZoKRNKedis1PtjzoO+KO+Wrj9wvKjbLpoTpzbvDhLqB/kPS9n7td+ cOTpAcPVqs2MZGSwI/eW5CMD4eEHbpXF8XfL0E5ZEGZFc29VhiVOJJi3J47vz5ygGgNC 0sI9Bal+xAzFAntAokuTKOL5wi2Uwaidws3JU+AejdMulNrav+npZBml2fd7aOddWIPU 2dT8yviPucozkF11PAu0hy0AHVJW+SD7ZgBhpfEm3pTbiviOcg6hsAVs3/Wi5T0m7ZoQ KSlZQRZADNXNxFQAwCyZu+8oOCQSigbHwrpVSynxSX+IPA/jnOAfvwc4+xsGyORhK7Em vhIQ== 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=CqWej1pJbw9VQ+2RWqU2qgHJJcvbelKT7IWL415TDHQIYYcafXprBecGlb/G5ahnZy P7KEFtdU4pYWY3Z+HV7RU67AK5YJcgJZSm6hk0iFMdz7wwYxt0AGFPVB2MppBzgwK9bp 58BzF6wiOn3Mw2vucVBt4qne25OB8NhVxdwd7/q0VR+VqRrCWLHvc0yh5fEOLrkfBtC7 iObKAN8DOs2YRF/BfgZ8n8J+TUjvymjewopkY9hvz4cy+1SOzJD8zdCPfLcXg2gzynze nnRkCtyeCB/+eZumF3mSNKx4gXHOPo+uHY0Jp/KhdNSa1UUDBRH85oZDW3Vj5tPXvKfe X8CA== X-Gm-Message-State: AOAM531QRu4K3LBfQRtwTKfoH4rRD3+ynEK4GbAQIBhCdhoQBil2gGiV fAgzARxstvgd8V9ScKWCc89ujW9YskzHVQ== X-Google-Smtp-Source: ABdhPJy0Gf9IjCyK8Aw1tRmhScaYxnlmJakDLgqqwL+SOliDEc/P8RNoLxoWix4p4Zs1qIzlNme8/Q== X-Received: by 2002:a63:fa11:: with SMTP id y17mr6294774pgh.128.1626214061143; Tue, 13 Jul 2021 15:07:41 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.183]) by smtp.gmail.com with ESMTPSA id w16sm94678pgi.41.2021.07.13.15.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 15:07:40 -0700 (PDT) From: G S Niteesh Babu To: qemu-devel@nongnu.org Subject: [PATCH v2 1/6] python: disable pylint errors for aqmp-tui Date: Wed, 14 Jul 2021 03:37:29 +0530 Message-Id: <20210713220734.26302-2-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210713220734.26302-1-niteesh.gs@gmail.com> References: <20210713220734.26302-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=niteesh.gs@gmail.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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 , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 Tue Jul 13 22:07:30 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: 1504906 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DaaupQIh; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GPZdz34Vyz9sX1 for ; Wed, 14 Jul 2021 08:13:27 +1000 (AEST) Received: from localhost ([::1]:41054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3Qeb-000420-49 for incoming@patchwork.ozlabs.org; Tue, 13 Jul 2021 18:13:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3QZ8-0001F4-91 for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:46 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:38709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3QZ6-000655-S9 for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:46 -0400 Received: by mail-pj1-x102a.google.com with SMTP id me13-20020a17090b17cdb0290173bac8b9c9so2215862pjb.3 for ; Tue, 13 Jul 2021 15:07:44 -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=DaaupQIhY5og8J5aMaC9T8h7i09/ZaFJDtat8+AFZXz0xiea3u8XArwXpbDKqd6zw8 qriGT7wIFvwtvBgATf5pcXQSZP3bb9u7ly6b1RJdSF+YvbxGLFgAc17k81KBl1Nm7XS1 OxAlEd7OIcx/ONy+3LX5xLmPF7oUzXx3/cSJXFtxCc7XMHxc3Z5RNMXXS+uvjVmlH3uQ hW8OkANXHC2Z5drEIfbgRFWJ/+YpgWD5QfILXC/bevjDff+60Zb+Ot34Q4m+Ca/1bL/a /pklYc/kLpgvx7jG0RZoWsowjdhZCjCa0XV78XqNn1nzQ4OQ7krVD2mgAIMRb6r8XcYF pl9A== 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=Pp3+3/T0T24EmE2SRvMczGg8uovEzdvUBOnNnLeW3ovVE+umxxVvCrlTNwfu4SQ3kY GBOZeWQAO8yX/MZGsbrCmA+fzKa9VFUs4OsUuYqO7XNOQPs2dj7ihIN6JaZblAdh+oJ4 IuqTL2TviJY0RGQ5duynnsPyNv7Qu+dFbnML+ndL2yFDSoOXIL82ETzbqjbb0/2VaKpo 4feahkO+a9nrEpP8dY3GrHpu9uNoJari7ggICz6ivbKdv+oJ54+8LnIHrX7/Fsk2FUat MZ8jWzmbq0ZLM+yf9IzElm5EDDXzsroRDUtm1qTsNNdX6GOhjfZPzigh7DBV+MN3OmBp c5UQ== X-Gm-Message-State: AOAM5314qvHjSD3XwMxapGtIej2lqYi/bjdtk7z39YJsxtybWnqJ9ges x+Hoxfo/THb85Cu1uhB8Z5dN+hsGJLQNhg== X-Google-Smtp-Source: ABdhPJyH0QooczI9Al8PV8ly3DZnyg6CZn0CaIZAXd/C+2+XHdybdwRd786nA6fDlif7MMgaZT/xuw== X-Received: by 2002:a17:90a:6782:: with SMTP id o2mr363791pjj.165.1626214063318; Tue, 13 Jul 2021 15:07:43 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.183]) by smtp.gmail.com with ESMTPSA id w16sm94678pgi.41.2021.07.13.15.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 15:07:43 -0700 (PDT) From: G S Niteesh Babu To: qemu-devel@nongnu.org Subject: [PATCH v2 2/6] python: Add dependencies for AQMP TUI Date: Wed, 14 Jul 2021 03:37:30 +0530 Message-Id: <20210713220734.26302-3-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210713220734.26302-1-niteesh.gs@gmail.com> References: <20210713220734.26302-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=niteesh.gs@gmail.com; helo=mail-pj1-x102a.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 , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 Tue Jul 13 22:07:31 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: 1504899 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=rmTuNDI8; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GPZXq4KS6z9sX1 for ; Wed, 14 Jul 2021 08:08:59 +1000 (AEST) Received: from localhost ([::1]:52822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3QaH-0001Jc-8M for incoming@patchwork.ozlabs.org; Tue, 13 Jul 2021 18:08:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3QZB-0001IL-BI for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:49 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:42584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3QZ9-000677-0f for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:49 -0400 Received: by mail-pj1-x1030.google.com with SMTP id i16-20020a17090acf90b02901736d9d2218so128486pju.1 for ; Tue, 13 Jul 2021 15:07:46 -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=HlLUgf9n6Oa6By93uK6f6O2qlQF33IzRRnBXuCDraNM=; b=rmTuNDI82PAYu6It0oPAPuo2eDwORcjUdMPxzywOYRlPVzeLU01No/POPlWCH+XLds VCSUoX8l6MQLAWuvy0mhgBPMWCFiOQM5wkIyYOItyQ7eQRDZH8qF3ESwqL1fhAY8PNdH ecGCbMo9NHlUIByfCVN3MGQ0fxEN9KQFidpDz0mrUhgBmwV9t1cnhZhUylBfn7NRwGuz JQzct4f/f9eEk8cpR9ljHB2b7+ZpTounUKgH9TPiMlHflY7rddB4wvrkGdoBANAWhs85 dkTjWjOUlyVxl2gLYQ95faP+c0wWyGXqwPdtfgKZok0StE+COsfyaRiBqm9iqnNz4SXE zrBg== 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=HlLUgf9n6Oa6By93uK6f6O2qlQF33IzRRnBXuCDraNM=; b=Het2EM1zNGmY4fTdMzhkTj47f8OTtrAYGeuHEQWKJ4kCrANWP/jSkPsB9pcFGTOhCR 89zbdjkwuBmKBKZncjvQGv4+me9we2CIk5X+zo4rGYM0pGT/xa2dG8BcxXhqP2CMDJBU wnwEiOZEnb0+EJigEk74xVi9QA8eb8ahTvuuUU5K4+6lQHORfmKpErEkdoK3nT6K6+hT ZrzhY6Bajo3ry1PWHMn47U1BxD2WxCfagIYbrwNgS28Wa26rlFSZZnGLlS+EuuswolYb 1dfnzDhNx0m2voQVFPEHtMR5FtxqU397E+hBMMek/1bTQf4y0R3ChN/ya4znmG9nUABr hyXg== X-Gm-Message-State: AOAM532fhkMMKVbRECiKUZcJVLC9ZfJiccotqyr+7e4/gaxrfwo17ohv F7aZzrZX/7dDSystJdTRmME7j2fgGDOCCg== X-Google-Smtp-Source: ABdhPJzqvj2mRa3CJg1h8DcMYv+K0XqP/57mSvwTx+OFpwoso6vOhg3MJSD42WYSD9p75wCQ9jnkVw== X-Received: by 2002:a17:90a:e611:: with SMTP id j17mr412065pjy.48.1626214065652; Tue, 13 Jul 2021 15:07:45 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.183]) by smtp.gmail.com with ESMTPSA id w16sm94678pgi.41.2021.07.13.15.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 15:07:45 -0700 (PDT) From: G S Niteesh Babu To: qemu-devel@nongnu.org Subject: [PATCH v2 3/6] python/aqmp-tui: Add AQMP TUI draft Date: Wed, 14 Jul 2021 03:37:31 +0530 Message-Id: <20210713220734.26302-4-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210713220734.26302-1-niteesh.gs@gmail.com> References: <20210713220734.26302-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=niteesh.gs@gmail.com; helo=mail-pj1-x1030.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 , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 | 332 +++++++++++++++++++++++++++++++++++ python/setup.cfg | 21 ++- 2 files changed, 352 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..f853efc1f5 --- /dev/null +++ b/python/qemu/aqmp/aqmp_tui.py @@ -0,0 +1,332 @@ +# 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 +from logging import Handler +import signal + +import urwid +import urwid_readline + +from .error import MultiException +from .protocol import ConnectError +from .qmp_protocol import QMP, ExecInterruptedError, ExecuteError +from .util import create_task, pretty_traceback + + +UPDATE_MSG = 'UPDATE_MSG' + +# Using root logger to enable all loggers under qemu and asyncio +LOGGER = logging.getLogger() + +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): + """ + 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', 20, 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, level=None): + formatted = [] + if level: + msg = f'[{level}]: {msg}' + formatted.append(msg) + else: + 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): + """ + 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(type(self), UPDATE_MSG) + self.window = Window(self) + self.address = address + self.aloop = None + self.loop = None + super().__init__() + + def add_to_history(self, msg, level=None): + urwid.emit_signal(self, UPDATE_MSG, msg, level) + + def _cb_outbound(self, msg): + LOGGER.debug('Request: %s', str(msg)) + self.add_to_history('<-- ' + str(msg)) + return msg + + def _cb_inbound(self, msg): + LOGGER.debug('Response: %s', str(msg)) + self.add_to_history('--> ' + 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: + await self._raw(bytes(msg, 'utf-8')) + except ExecuteError: + LOGGER.info('Error response from server for msg: %s', msg) + except ExecInterruptedError: + LOGGER.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: + LOGGER.error('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 + try: + await self.disconnect() + LOGGER.debug('Disconnect finished. Exiting app') + except MultiException as err: + LOGGER.info('Multiple exception on disconnect: %s', str(err)) + # Let the app crash after providing a proper stack trace + raise err + raise urwid.ExitMainLoop() + + def handle_event(self, event): + # FIXME: Consider all states present in qapi/run-state.json + 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: + LOGGER.debug('Cannot connect to server %s', str(err)) + self.window.footer.set_text('Server shutdown') + + def run(self, debug=False): + self.screen.set_terminal_properties(256) + + self.aloop = asyncio.get_event_loop() + self.aloop.set_debug(debug) + + # 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) + + 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: + LOGGER.error('%s\n%s\n', str(err), pretty_traceback()) + raise err + + +class TUILogHandler(Handler): + def __init__(self, tui): + super().__init__() + self.tui = tui + + def emit(self, record): + level = record.levelname + msg = record.getMessage() + self.tui.add_to_history(msg, level) + + +def parse_address(address): + """ + This snippet was taken from qemu.qmp.__init__. + pylint complaints about duplicate code so it has been + temprorily disabled. This should be fixed once qmp is + replaced by aqmp in the future. + """ + components = address.split(':') + if len(components) == 2: + try: + port = int(components[1]) + except ValueError: + raise ValueError(f'Bad Port value in {address}') from None + return (components[0], port) + return address + + +def main(): + parser = argparse.ArgumentParser(description='AQMP TUI') + parser.add_argument('qmp_server', help='Address of the QMP server' + '< UNIX socket path | TCP addr:port >') + parser.add_argument('--log-file', help='The Log file name') + parser.add_argument('--log-level', help='Log level ', + default='debug') + parser.add_argument('--debug', action='store_true', + help='Enable debug mode for asyncio loop' + 'Generates lot of output, makes TUI unusable when' + 'logs are logged in the TUI itself.' + 'Use only when logging to a file') + args = parser.parse_args() + + try: + address = parse_address(args.qmp_server) + except ValueError as err: + parser.error(err) + + app = App(address) + + if args.log_file: + LOGGER.addHandler(logging.FileHandler(args.log_file)) + else: + LOGGER.addHandler(TUILogHandler(app)) + + log_levels = {'debug': logging.DEBUG, + 'info': logging.INFO, + 'error': logging.ERROR} + + if args.log_level not in log_levels: + parser.error('Invalid log level') + LOGGER.setLevel(log_levels[args.log_level]) + + app.run(args.debug) + + +if __name__ == '__main__': + main() # type: ignore diff --git a/python/setup.cfg b/python/setup.cfg index c62803bffc..7e5aae66c7 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] @@ -97,6 +111,11 @@ ignore_missing_imports = True # --disable=W". disable=too-many-function-args, # mypy handles this with less false positives. missing-docstring, # FIXME + # pylint complaints about duplicate code in aqmp_tui. The snippet is + # taken from qemu/qmp and there is no way to turn this check of in + # module itself. So this has been added here and has to be removed + # in the future when qmp is removed. + duplicate-code, # FIXME fixme, # FIXME [pylint.basic] From patchwork Tue Jul 13 22:07:32 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: 1504900 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ZzEAFcpX; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GPZXs4dCqz9sX1 for ; Wed, 14 Jul 2021 08:09:01 +1000 (AEST) Received: from localhost ([::1]:52892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3QaJ-0001Mr-DN for incoming@patchwork.ozlabs.org; Tue, 13 Jul 2021 18:08:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3QZC-0001Jb-J9 for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:51 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:41544) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3QZB-000690-4b for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:50 -0400 Received: by mail-pj1-x102f.google.com with SMTP id oj10-20020a17090b4d8ab0290172f77377ebso143464pjb.0 for ; Tue, 13 Jul 2021 15:07:48 -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=CIT5Qi+TmHYy1A7fr2pjHtK64KmgdsTMU/FvGBocCwo=; b=ZzEAFcpXy15NS/tpYV5KUXSNlQszmp20JMmyPQPUFEPZZgDIHUoodl4P2wozG1SF8N n6R7fBw0FLDW8wNgXWLMFA+UN7xYfJoJyGeyKFUQkQ8v+0dOvVRpG2YcG921sEHLAqOA 2gS0kYxOkrfjYGXN1+Eer7zpa3wlNhE+aTnnaeHzOqLj6PWif4MApsgUwu+0xmPfIPyO EdDUp/MQDI0EAm5Irpg0Efldjdb//syeKR76LvyIRuTEE+tawjw0BxSZDOtbbDc7ifXh sTIHoUuvThqTLaBoxlO9nQmRkQMIvmmb5DnLgWO/Ltu/E9uQbKx5Q/DBY63Yb/Q88Kqn OzWg== 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=CIT5Qi+TmHYy1A7fr2pjHtK64KmgdsTMU/FvGBocCwo=; b=ia+Qn9t7SxED75Xr792Eavia8gZ3a1ngWNJifVW1Vken4d3dekWUgWAfVumHzfpYgi VHDQWEdyi2D+a2mBw5hwHbnd2Zh+mPhNGs6qeYR+fnHfErE95cICb9GIZB6CsQ3jo/Y4 N4KI+uW7nFqLSNH/GMjvOJyr3E+vom+N5cSXmk1VHv23BIdE4pnUOYql9x7XoG2E1xKI D2CNNoajPjsTnvD0NNgN8+oq/7Q4tPdo+6h/8P9+fGp/DvtxOSxDt5UT3CQ94rCaqvNk +ZMfcVxY+wD2kOAp/8c65MfFBJK/QTUBBIS8ooT7AvZ8Kvp766bciADAsApsdCBvwvVI LcwQ== X-Gm-Message-State: AOAM532Wtrf3W534P/H9TToTxaK065ki5UG018qtrk0Kv37AoPQIjZ3Z L0wPt1vAknhoR9crlxqwXc6f/i6jtQ4w6w== X-Google-Smtp-Source: ABdhPJzPe+z9JeU99Ts/ydTtTZlovnYfwpe1oud6onRZZtC4XqDIVYCDe59Nv4T0QlND/slizlwaxA== X-Received: by 2002:a17:90b:110c:: with SMTP id gi12mr4043282pjb.163.1626214067878; Tue, 13 Jul 2021 15:07:47 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.183]) by smtp.gmail.com with ESMTPSA id w16sm94678pgi.41.2021.07.13.15.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 15:07:47 -0700 (PDT) From: G S Niteesh Babu To: qemu-devel@nongnu.org Subject: [PATCH v2 4/6] python: add optional pygments dependency Date: Wed, 14 Jul 2021 03:37:32 +0530 Message-Id: <20210713220734.26302-5-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210713220734.26302-1-niteesh.gs@gmail.com> References: <20210713220734.26302-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=niteesh.gs@gmail.com; helo=mail-pj1-x102f.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 , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 7e5aae66c7..63f5156c03 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 Tue Jul 13 22:07:33 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: 1504901 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=slROXEZH; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GPZXt32kzz9sX1 for ; Wed, 14 Jul 2021 08:09:02 +1000 (AEST) Received: from localhost ([::1]:52994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3QaK-0001Qz-4Y for incoming@patchwork.ozlabs.org; Tue, 13 Jul 2021 18:09:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3QZG-0001Nf-Ab for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:54 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:46810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3QZD-00069z-CL for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:52 -0400 Received: by mail-pj1-x1034.google.com with SMTP id b5-20020a17090a9905b029016fc06f6c5bso112268pjp.5 for ; Tue, 13 Jul 2021 15:07:51 -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=MFX1bAKDxzO1WS9SbmpB1APYv3Ko7UqDEMVqBQ4qfPg=; b=slROXEZHTZ6JwnPiaQkPIDdwWaM55EKsXI7iUIoBhqPWwGsaxDOxzG5xrLSpxUTL+2 qIUMhuBCbvGFs2O3Ut2GniiMRAT+c9JUdDy0ah2garMy5SsgYJxceqQZWWVO6eU6iUOE 4+ZS3gBs6lxmHJ0vgnEU6JrMEejwpTOplAJrDh4YjBEnWVK862TPURhc+ILXLYu/zIXO h0mg5iM/MP+fsvrnMgGi4mAhZXM344ewOhnNvnpC2nIoxq7xIViSXgztdSeqeX+djo// kqbHDG1I27NLakUdG8RIQjU/KCA6ljjIRtLciy57mJU4V+vonVQAjYIR8tzsB0GRLuP+ IKlA== 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=MFX1bAKDxzO1WS9SbmpB1APYv3Ko7UqDEMVqBQ4qfPg=; b=CWO3upXWVu3HYBSXZo/IpPd7MmH53l8TmyayPYeruWqziGRiE/vylW50RWJ8U9MGmr xoK2XjWQzIk3inkoCbt7LGad1KSTLuD1cLmiGLGFmL2A8ZlX+gN00i24BRSB8n4EOv3j FjN08o+YvwA6eIrMO7g/8NzBoegBsDRgPGCXQql9+eU+bBSvCV+WVUoeC0tQ7JhDxLR3 gDyVydRWBK6tcQ+arZE41ZErOXorDYZm2mN0loyGFPSYO1pr/qE2/L8NJ8hlFCNlBPm9 4CihLLiEsdPUmXQxZ2UJZgYsY4qSH/lA1p+zPQrm5D3gtGgxGXhtdXKNeyEFT1sYG8Q3 YVIw== X-Gm-Message-State: AOAM530XI1WIORyvfq8pa6ysRA6xdv/JEva7KLzAFZd/wy2Z40DosigL 6iIp5E+7hf710ipRBYjoXF2wDrIuytXF9A== X-Google-Smtp-Source: ABdhPJzTndxhdbbfuRRh0jRUjT0NLPi+gJlKBzick3mxRcwSebDPfwu0OHSIfxiIweFHA/iwqnJwHw== X-Received: by 2002:a17:90b:347:: with SMTP id fh7mr420399pjb.2.1626214070032; Tue, 13 Jul 2021 15:07:50 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.183]) by smtp.gmail.com with ESMTPSA id w16sm94678pgi.41.2021.07.13.15.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 15:07:49 -0700 (PDT) From: G S Niteesh Babu To: qemu-devel@nongnu.org Subject: [PATCH v2 5/6] python/aqmp-tui: add syntax highlighting Date: Wed, 14 Jul 2021 03:37:33 +0530 Message-Id: <20210713220734.26302-6-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210713220734.26302-1-niteesh.gs@gmail.com> References: <20210713220734.26302-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 , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py index f853efc1f5..9ee91f0e99 100644 --- a/python/qemu/aqmp/aqmp_tui.py +++ b/python/qemu/aqmp/aqmp_tui.py @@ -12,6 +12,8 @@ from logging import Handler import signal +from pygments import lexers +from pygments import token as Token import urwid import urwid_readline @@ -33,6 +35,11 @@ (Token.Literal.Number.Integer, '', '', '', '#fa0', 'g7'), (Token.Literal.String.Double, '', '', '', '#6f6', 'g7'), (Token.Keyword.Constant, '', '', '', '#6af', 'g7'), + ('DEBUG', '', '', '', '#ddf', 'g7'), + ('INFO', '', '', '', 'g100', 'g7'), + ('WARNING', '', '', '', '#ff6', 'g7'), + ('ERROR', '', '', '', '#a00', 'g7'), + ('CRITICAL', '', '', '', '#a00', 'g7'), ('background', '', 'black', '', '', 'g7'), ] @@ -133,7 +140,7 @@ def cb_add_to_history(self, msg, level=None): formatted = [] if level: msg = f'[{level}]: {msg}' - formatted.append(msg) + formatted.append((level, msg)) else: lexer = lexers.JsonLexer() # pylint: disable=no-member for token in lexer.get_tokens(msg): @@ -162,6 +169,7 @@ def __init__(self, address): self.address = address self.aloop = None self.loop = None + self.screen = urwid.raw_display.Screen() super().__init__() def add_to_history(self, msg, level=None): @@ -249,8 +257,10 @@ def run(self, debug=False): self.aloop.add_signal_handler(sig, self.kill_app) 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 Tue Jul 13 22:07:34 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: 1504904 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=YrEsiC9O; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GPZbk2Q2dz9sXJ for ; Wed, 14 Jul 2021 08:11:30 +1000 (AEST) Received: from localhost ([::1]:33310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3Qci-0007Bh-1e for incoming@patchwork.ozlabs.org; Tue, 13 Jul 2021 18:11:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3QZI-0001R6-OT for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:57 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:46882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3QZG-0006BZ-3H for qemu-devel@nongnu.org; Tue, 13 Jul 2021 18:07:56 -0400 Received: by mail-pl1-x62e.google.com with SMTP id c15so126939pls.13 for ; Tue, 13 Jul 2021 15:07:52 -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=A7NQ0ep9pW2suRHd8fMyEP5903fARm1EdM1W099gVSk=; b=YrEsiC9OBdak0qCOuFVbRFEwZbbKG9kK179z/6a2NUNoSetYcMn1Ifl/YSpJb04DhS rTX10tI0P7jbKW6eQ+ei9NkDLdDh0QQcL8swupXEEcXRV86EEYZZlBYjmqAugB/h95bM UZWSk+b1EZqxqRyLmvExvaMOPb1na693HKWZ0Ee/t0OHgJ+MofzzjpoPQtcRaLeDMYJA kJpYOrLBUVq7qVQgbQZC+jsVATr/WcPyQiGFLsztWG59QpalSSI+H3ge4PgsrSzHp0ol cYxPZTtxy3RL5gVFKptDB0s3vGr9tBRr5CdVyu5bclZJOnGHphZeGmfsFp8fpFEchuDJ lOHA== 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=A7NQ0ep9pW2suRHd8fMyEP5903fARm1EdM1W099gVSk=; b=SoxS4gMXMB/MRWBmbmfG+yMorGfK4Pt8nSOPEJXcy/urdiCIqD9V2bKlyHevxzIucS 9PQr8Qxpbl+z+yM8XBfNM38kg2ufLNTjLVF6i4jh5VXG1xOi7jAiju9hvk2wAxru55Kv XMvLZbGCGz7CGEtbpCqr46YGJPJGvwqnyPyBIVoLZ6I3io0SHsn9sAUOiUMtn5hpPrkH XECdPCJgQSsbVBFbIERlqXfZO5CIVrN/QK0ZKUTpTteDJWNVwnXEWBT8czhKxDtEPpPd aldNYek9+MnnBATkgzaepA6mlP5uM8Gyi/O1ZI9zkeM+UZJT6lVj52eM3n3G7x2yXJ57 vibg== X-Gm-Message-State: AOAM530YgzO98Z0AuhquPh6wXUenljeom/F9A4VVmHOEWTTDz6+65wU2 xr4uU9UdFQUnvcYZZ90CUELnWXVu0DuPdQ== X-Google-Smtp-Source: ABdhPJwL0sT3REGRyGgvZ27RxO6rJjbE5wsVkl+EUODwj9ra69g8tqpUdglB/YhfAQQb+wMFh0+pZQ== X-Received: by 2002:a17:90b:3757:: with SMTP id ne23mr417400pjb.72.1626214072066; Tue, 13 Jul 2021 15:07:52 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.183]) by smtp.gmail.com with ESMTPSA id w16sm94678pgi.41.2021.07.13.15.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 15:07:51 -0700 (PDT) From: G S Niteesh Babu To: qemu-devel@nongnu.org Subject: [PATCH v2 6/6] python: add entry point for aqmp-tui Date: Wed, 14 Jul 2021 03:37:34 +0530 Message-Id: <20210713220734.26302-7-niteesh.gs@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210713220734.26302-1-niteesh.gs@gmail.com> References: <20210713220734.26302-1-niteesh.gs@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=niteesh.gs@gmail.com; helo=mail-pl1-x62e.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 , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 localhost:1234" More options available in the TUI can be found using "aqmp-tui -h" 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 63f5156c03..082bb6d68b 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