From nobody Wed Jul 16 12:18:25 2025 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622822925; cv=none; d=zohomail.com; s=zohoarc; b=HY847gOHIGZO8Cj+2nzt6Y0FhiL6X3Ssn5SV8jkuXk9wcvrUi6v/6uDuC+ldpvFLODcZWdx1k/fXmiit9hFhRhfp1gV1J1k4/Dg2cBRY8MopxTOF/ZZZxhv/aT0i0QVL8Xesxf1SuVWCbN7JOmZXWELMb4KXNsd27gKoL2YSJbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622822925; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8QZLQkMFCMaEsiD+0Lrc8dRGYjO8zJRP6vlPMh9DRK0=; b=am8lpw+/ojpBBeYv+NHd8hzlrd7gFNdStwSPvB2/IKPe1Xduvm2nUClct+qD3KBlLpRBt+4ZvwKyXppyHJ51bYdz39uh7QjeSHxUTEvhAldSKe7+W8Id3Bc5fRupM1avW0vrB1eQlOu786tAa7TOsaFN11+6s3DRA9XPqQJ8A0U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162282292583965.49963672351566; Fri, 4 Jun 2021 09:08:45 -0700 (PDT) Received: from localhost ([::1]:60388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCNI-0008Tk-HO for importer2@patchew.org; Fri, 04 Jun 2021 12:08:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAr-00019Q-Uj for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAi-0001VS-AJ for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-YbscPlFgNI61E0FhCNpYjg-1; Fri, 04 Jun 2021 11:55:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 941AD9F92B; Fri, 4 Jun 2021 15:55:40 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id D192D50C0A; Fri, 4 Jun 2021 15:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8QZLQkMFCMaEsiD+0Lrc8dRGYjO8zJRP6vlPMh9DRK0=; b=blnMXfBXhZgs6WxRhFEi03KkqnBHqlHCuSyhRTaW75XS/Gzr6Sx2zDM6VdfySUQ5c3SK3I dq/yRem4UEOUwyrZXYHAjlKArX2Mtvz2nhzgpeR8Lu9oGympRo4V4RyDoG/I/4dfjkmYmb 3PcdYCIjE16cAdfTb/mEy1SsoVOwh00= X-MC-Unique: YbscPlFgNI61E0FhCNpYjg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 06/11] scripts/qemu-ga-client: apply (most) pylint rules Date: Fri, 4 Jun 2021 11:55:27 -0400 Message-Id: <20210604155532.1499282-7-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" I'm only doing a very quick best-effort to preserve this script, to help keep it from breaking further. I think there are pending ideas swirling on the right way to implement better SDKs and better clients, and this script might be a handy reference for those discussions. It presents some interesting design problems, like static type safety when using a dynamic RPC mechanism. I believe it's worth preserving the effort and care that went into making this script by updating it to work with our current infrastructure. However, I am disabling the requirement for docstrings in this file. If you would like to help improve this script, please add docstrings alongside any refactors or rejuvenations you might apply at that time. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index e81937e0ea..ece9f74fa8 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -40,6 +40,7 @@ See also: https://wiki.qemu.org/Features/QAPI/GuestAgent =20 import argparse import base64 +import errno import os import random import sys @@ -49,6 +50,13 @@ sys.path.append(os.path.join(os.path.dirname(__file__), = '..', '..', 'python')) from qemu import qmp =20 =20 +# This script has not seen many patches or careful attention in quite +# some time. If you would like to improve it, please review the design +# carefully and add docstrings at that point in time. Until then: + +# pylint: disable=3Dmissing-docstring + + class QemuGuestAgent(qmp.QEMUMonitorProtocol): def __getattr__(self, name): def wrapper(**kwds): @@ -104,7 +112,8 @@ class QemuGuestAgentClient: =20 return '\n'.join(msgs) =20 - def __gen_ipv4_netmask(self, prefixlen): + @classmethod + def __gen_ipv4_netmask(cls, prefixlen): mask =3D int('1' * prefixlen + '0' * (32 - prefixlen), 2) return '.'.join([str(mask >> 24), str((mask >> 16) & 0xff), @@ -207,10 +216,12 @@ def _cmd_fstrim(client, args): =20 =20 def _cmd_ifconfig(client, args): + assert not args print(client.ifconfig()) =20 =20 def _cmd_info(client, args): + assert not args print(client.info()) =20 =20 @@ -239,6 +250,7 @@ def _cmd_suspend(client, args): =20 =20 def _cmd_shutdown(client, args): + assert not args client.shutdown() =20 =20 @@ -246,10 +258,12 @@ _cmd_powerdown =3D _cmd_shutdown =20 =20 def _cmd_halt(client, args): + assert not args client.shutdown('halt') =20 =20 def _cmd_reboot(client, args): + assert not args client.shutdown('reboot') =20 =20 @@ -269,8 +283,6 @@ def send_command(address, cmd, args): try: client =3D QemuGuestAgentClient(address) except OSError as err: - import errno - print(err) if err.errno =3D=3D errno.ECONNREFUSED: print('Hint: qemu is not running?') --=20 2.31.1