From patchwork Tue Feb 9 11:37:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8260221 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 20A969F8AA for ; Tue, 9 Feb 2016 11:38:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78DC32025A for ; Tue, 9 Feb 2016 11:38:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B37B320254 for ; Tue, 9 Feb 2016 11:38:25 +0000 (UTC) Received: from localhost ([::1]:54549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT6cj-0007qm-28 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 09 Feb 2016 06:38:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT6cT-0007on-9w for qemu-devel@nongnu.org; Tue, 09 Feb 2016 06:38:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aT6cQ-0002xM-DB for qemu-devel@nongnu.org; Tue, 09 Feb 2016 06:38:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37498) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT6cP-0002x1-Us for qemu-devel@nongnu.org; Tue, 09 Feb 2016 06:38:06 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 9413B8F4FB for ; Tue, 9 Feb 2016 11:38:05 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u19Bc36E025238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 9 Feb 2016 06:38:05 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5BC9F3011F90; Tue, 9 Feb 2016 12:38:03 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 9 Feb 2016 12:37:34 +0100 Message-Id: <1455017883-25867-3-git-send-email-armbru@redhat.com> In-Reply-To: <1455017883-25867-1-git-send-email-armbru@redhat.com> References: <1455017883-25867-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/31] scripts/qmp: Use Python 2.6 "except E as ..." syntax X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP PEP 8 calls for it, because it's forward compatible with Python 3. Supported since Python 2.6, which we require (commit fec2103). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Acked-by: Stefan Hajnoczi Message-Id: <1450425164-24969-3-git-send-email-armbru@redhat.com> --- scripts/qmp/qemu-ga-client | 2 +- scripts/qmp/qmp | 4 ++-- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qmp.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 9908f21..fd05605 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -259,7 +259,7 @@ def main(address, cmd, args): try: client = QemuGuestAgentClient(address) - except QemuGuestAgent.error, e: + except QemuGuestAgent.error as e: import errno print(e) diff --git a/scripts/qmp/qmp b/scripts/qmp/qmp index 1db3c7f..514b539 100755 --- a/scripts/qmp/qmp +++ b/scripts/qmp/qmp @@ -91,8 +91,8 @@ def main(args): try: os.environ['QMP_PATH'] = path os.execvp(fullcmd, [fullcmd] + args) - except OSError, (errno, msg): - if errno == 2: + except OSError as exc: + if exc.errno == 2: print 'Command "%s" not found.' % (fullcmd) return 1 raise diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index fa39bf0..7a402ed 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -240,7 +240,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): def _execute_cmd(self, cmdline): try: qmpcmd = self.__build_cmd(cmdline) - except Exception, e: + except Exception as e: print 'Error while parsing command line: %s' % e print 'command format: ', print '[arg-name1=arg1] ... [arg-nameN=argN]' diff --git a/scripts/qmp/qmp.py b/scripts/qmp/qmp.py index 1d38e3e..779332f 100644 --- a/scripts/qmp/qmp.py +++ b/scripts/qmp/qmp.py @@ -92,7 +92,7 @@ class QEMUMonitorProtocol: self.__sock.setblocking(0) try: self.__json_read() - except socket.error, err: + except socket.error as err: if err[0] == errno.EAGAIN: # No data available pass @@ -150,7 +150,7 @@ class QEMUMonitorProtocol: """ try: self.__sock.sendall(json.dumps(qmp_cmd)) - except socket.error, err: + except socket.error as err: if err[0] == errno.EPIPE: return raise socket.error(err)