From nobody Fri May 3 04:47:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152182347546780.83109510040788; Fri, 23 Mar 2018 09:44:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E07C80E7E; Fri, 23 Mar 2018 16:44:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A63D51692B; Fri, 23 Mar 2018 16:44:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5932A1806104; Fri, 23 Mar 2018 16:44:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2NGiSZf004699 for ; Fri, 23 Mar 2018 12:44:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 49E4E215CDAC; Fri, 23 Mar 2018 16:44:28 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD914215CDA7; Fri, 23 Mar 2018 16:44:27 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 23 Mar 2018 16:44:25 +0000 Message-Id: <20180323164425.18193-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH sandbox] Fix argparser incompatibilities with newer python 3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 23 Mar 2018 16:44:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Python 3 changes such that if no subparser command is listed, it just throws an error. To get back the old behavior we need to set the 'required' attribute and a dest name. Since we treat 'debug' as a global attribute we need to set that on the top level parser too, otherwise we get a missing attribute error with newish python 3 too. Signed-off-by: Daniel P. Berrang=C3=A9 --- libvirt-sandbox/image/cli.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libvirt-sandbox/image/cli.py b/libvirt-sandbox/image/cli.py index 490c5e0..d2035de 100644 --- a/libvirt-sandbox/image/cli.py +++ b/libvirt-sandbox/image/cli.py @@ -202,7 +202,6 @@ Example supported URI formats: def gen_purge_args(subparser): parser =3D gen_command_parser(subparser, "purge", _("Purge cached template")) - requires_debug(parser) requires_template(parser) requires_template_dir(parser) parser.set_defaults(func=3Dpurge) @@ -210,7 +209,6 @@ def gen_purge_args(subparser): def gen_prepare_args(subparser): parser =3D gen_command_parser(subparser, "prepare", _("Prepare local template")) - requires_debug(parser) requires_template(parser) requires_connect(parser) requires_template_dir(parser) @@ -219,7 +217,6 @@ def gen_prepare_args(subparser): def gen_run_args(subparser): parser =3D gen_command_parser(subparser, "run", _("Run an instance of a template")) - requires_debug(parser) requires_name(parser) requires_template(parser) requires_connect(parser) @@ -238,7 +235,6 @@ def gen_run_args(subparser): def gen_list_args(subparser): parser =3D gen_command_parser(subparser, "list", _("List locally cached images")) - requires_debug(parser) requires_template_dir(parser) =20 parser.add_argument("-s","--source", @@ -249,7 +245,11 @@ def gen_list_args(subparser): def main(): parser =3D argparse.ArgumentParser(description=3D"Sandbox Container Im= age Tool") =20 + requires_debug(parser) + subparser =3D parser.add_subparsers(help=3D_("commands")) + subparser.required =3D True + subparser.dest =3D "command" gen_purge_args(subparser) gen_prepare_args(subparser) gen_run_args(subparser) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list