From nobody Mon May 6 05:53:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587974911; cv=none; d=zohomail.com; s=zohoarc; b=bzDTW61wESK+Db0/oECIBtQ3A3A2PIzZ2Uc4A6Ii5ECFXb3y3Zrm7U1TrBSmvjgag7h5dBwE95DrWxy4ScJucTp7Ud+tuwlK4B5BH86QWxwxTGnVirS0IufkSeiJQY84n5cpBD+lZYe23Lxvv2u550kfIsrQ/xEaIYBcYXyCJkw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587974911; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=OzSEcmyKQIX0z0oVBxMSepMtTTni6eXwU2jAvKlbyFo=; b=V1gjm6azyRpEAD7MdIWrJahJO4UQh+qdxhnhDrzhgFgiODpgo9b4fcm8T7uC4rLA7vcRxfVjouIvNOENws5DTitDPTgzQDqH6Ul6wkljaBr1LxOqJS45hlwTPwUO4EpYA6iOBspyB9p23pLEdnJAOj3K6w7EEQ3HZHzVgU7hoDQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1587974911354170.9505997863688; Mon, 27 Apr 2020 01:08:31 -0700 (PDT) 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-456-RWN0RO9UP3iNz-44qOdW1A-1; Mon, 27 Apr 2020 04:08:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 570C2800C78; Mon, 27 Apr 2020 08:08:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0DE3A27CC9; Mon, 27 Apr 2020 08:08:22 +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 821F14CA94; Mon, 27 Apr 2020 08:08:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03R88JLs018299 for ; Mon, 27 Apr 2020 04:08:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id AF72A2026FFE; Mon, 27 Apr 2020 08:08:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABC432026D69 for ; Mon, 27 Apr 2020 08:08:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12026811E7A for ; Mon, 27 Apr 2020 08:08:16 +0000 (UTC) Received: from mail.univention.de (mail.univention.de [82.198.197.8]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-ir56JobsM9SXLDeJgjgHlQ-1; Mon, 27 Apr 2020 04:08:12 -0400 Received: from localhost (localhost [127.0.0.1]) by solig.knut.univention.de (Postfix) with ESMTP id 98A7D8F60A2B for ; Mon, 27 Apr 2020 10:08:10 +0200 (CEST) Received: from mail.univention.de ([127.0.0.1]) by localhost (solig.knut.univention.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C_URH-OLSU6X; Mon, 27 Apr 2020 10:08:09 +0200 (CEST) Received: from fixa.knut.univention.de (p5B21E6AF.dip0.t-ipconnect.de [91.33.230.175]) by solig.knut.univention.de (Postfix) with ESMTPSA id 5C82A8F60A20; Mon, 27 Apr 2020 10:08:09 +0200 (CEST) Received: by fixa.knut.univention.de (Postfix, from userid 2260) id A6C0015F7FA; Mon, 27 Apr 2020 10:08:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587974909; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=OzSEcmyKQIX0z0oVBxMSepMtTTni6eXwU2jAvKlbyFo=; b=M7eqTDTLpkTmoLo/e/p6K9pf7uvvorl0r32S5VRaNsOTSUZqkA/MqrAtXmISecE22w1hGG KCqdw2Q1X0g4DI1MWfuM0fG6Qal0QvUcxzs66LSRnsHtO233R5+oUcL7tnB2sIjB2JKdPo /DjBXE8CvVzYVYK9V6DuRB9g7SDuiVw= X-MC-Unique: RWN0RO9UP3iNz-44qOdW1A-1 X-MC-Unique: ir56JobsM9SXLDeJgjgHlQ-1 X-Virus-Scanned: by amavisd-new-2.10.1 (20141025) (Debian) at knut.univention.de From: Philipp Hahn To: libvir-list@redhat.com Subject: [PATCH libvirt-python] examples: Fix connection error handling 2 Date: Mon, 27 Apr 2020 10:08:08 +0200 Message-Id: <8b73b1326b2d2940dc9c63cd47ba0b16a6506417.1587974869.git.hahn@univention.de> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 03R88JLs018299 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Fix two more cases in examples as libvirt.open*() does not return None but raises an exception Fixes: 283e2bc693746164b22226e14d6fe3ccd38a07bf Signed-off-by: Philipp Hahn Reviewed-by: Michal Privoznik --- examples/dhcpleases.py | 5 +++-- examples/domipaddrs.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/dhcpleases.py b/examples/dhcpleases.py index f394541..6f80fd5 100755 --- a/examples/dhcpleases.py +++ b/examples/dhcpleases.py @@ -22,8 +22,9 @@ else: usage() sys.exit(2) =20 -conn =3D libvirt.open(uri) -if conn =3D=3D None: +try: + conn =3D libvirt.open(uri) +except libvirt.libvirtError: print("Unable to open connection to libvirt") sys.exit(1) =20 diff --git a/examples/domipaddrs.py b/examples/domipaddrs.py index bda308c..e893995 100755 --- a/examples/domipaddrs.py +++ b/examples/domipaddrs.py @@ -21,8 +21,9 @@ else: usage() sys.exit(2) =20 -conn =3D libvirt.open(uri) -if conn =3D=3D None: +try: + conn =3D libvirt.open(uri) +except libvirt.libvirtError: print "Unable to open connection to libvirt" sys.exit(1) =20 --=20 2.20.1