From patchwork Mon Mar 2 16:05:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Conole X-Patchwork-Id: 1247728 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=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OrTOfRdZ; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48WQ320LBbz9sRY for ; Tue, 3 Mar 2020 03:05:17 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2368685CCF; Mon, 2 Mar 2020 16:05:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CWB2o6K02LtJ; Mon, 2 Mar 2020 16:05:14 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id B503684237; Mon, 2 Mar 2020 16:05:14 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9A23FC1AE2; Mon, 2 Mar 2020 16:05:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id EE8FAC013E for ; Mon, 2 Mar 2020 16:05:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id DC33D204A0 for ; Mon, 2 Mar 2020 16:05:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t3OX8wQ53IVH for ; Mon, 2 Mar 2020 16:05:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by silver.osuosl.org (Postfix) with ESMTPS id 37E7B2049F for ; Mon, 2 Mar 2020 16:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583165110; h=from:from: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; bh=wBBTv/fCpJIXx5gda1Pa8e/sedw/Z1en/LJ6yHXNQyY=; b=OrTOfRdZtjCDvEkiMh2DNBdqfDvbbvP190e1tK5wGFRfYqtA4ro4JN4fFDS9Aq7QMEscNx KEWYqjs6wSQBOiG9zAWKDUExjs3a6K8KvPa4WsdOyAqryJe9qvnekcljxFBw4a/9ioTaCw DNxgyS3Wc3X8GvT2GE/hXFeVOjtywQs= 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-268-CIATOTyHPZO_PiRUK1C63g-1; Mon, 02 Mar 2020 11:05:09 -0500 X-MC-Unique: CIATOTyHPZO_PiRUK1C63g-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27B068017CC for ; Mon, 2 Mar 2020 16:05:08 +0000 (UTC) Received: from dhcp-25.97.bos.redhat.com (unknown [10.18.25.177]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBAAE60C87 for ; Mon, 2 Mar 2020 16:05:07 +0000 (UTC) From: Aaron Conole To: dev@openvswitch.org Date: Mon, 02 Mar 2020 11:05:06 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH] ovs-dpctl-top: python3 compatibility X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" During the transition to python3 support, some syntax errors weren't adequately cleaned. This addresses the various errors, plus one minor issue with string type conversion. Signed-off-by: Aaron Conole Tested-by: Flavio Leitner Acked-by: Flavio Leitner --- --- diff --git a/utilities/ovs-dpctl-top.in b/utilities/ovs-dpctl-top.in index f2cc3f7f2a..011cc64b74 100755 --- a/utilities/ovs-dpctl-top.in +++ b/utilities/ovs-dpctl-top.in @@ -592,7 +592,7 @@ def flows_read(ihdl, flow_db): try: flow_db.flow_line_add(line) - except ValueError, arg: + except ValueError as arg: logging.error(arg) return flow_db @@ -958,6 +958,9 @@ class FlowDB: change order of fields of the same flow. """ + if not isinstance(line, str): + line = str(line) + line = line.rstrip("\n") (fields, stats, _) = flow_line_split(line) @@ -988,7 +991,7 @@ class FlowDB: self.flow_event(fields_dict, stats_old_dict, stats_dict) - except ValueError, arg: + except ValueError as arg: logging.error(arg) self._error_count += 1 raise @@ -1192,7 +1195,7 @@ def flows_top(args): flows_read(ihdl, flow_db) finally: ihdl.close() - except OSError, arg: + except OSError as arg: logging.critical(arg) break @@ -1220,7 +1223,7 @@ def flows_top(args): # repeat output for (count, line) in lines: - print line + print(line) def flows_script(args): @@ -1249,7 +1252,7 @@ def flows_script(args): render = Render(console_width, Render.FIELD_SELECT_SCRIPT) for line in render.format(flow_db): - print line + print(line) def main():