From patchwork Tue Jul 24 16:35:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timothy Redaelli X-Patchwork-Id: 948606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZkW83WzKz9ryt for ; Wed, 25 Jul 2018 02:35:48 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8C568DB7; Tue, 24 Jul 2018 16:35:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 4545DDB4 for ; Tue, 24 Jul 2018 16:35:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DFDF77C4 for ; Tue, 24 Jul 2018 16:35:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2FD8D40201BD for ; Tue, 24 Jul 2018 16:35:26 +0000 (UTC) Received: from localhost.localdomain (dhcp189-71.ntdv.lab.eng.bos.redhat.com [10.19.189.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id A85501C581 for ; Tue, 24 Jul 2018 16:35:25 +0000 (UTC) From: Timothy Redaelli To: dev@openvswitch.org Date: Tue, 24 Jul 2018 18:35:22 +0200 Message-Id: <85d64d647576215ebd9fcbcfb04dced86ee11ee0.1532449658.git.tredaelli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 24 Jul 2018 16:35:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 24 Jul 2018 16:35:26 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'tredaelli@redhat.com' RCPT:'' X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] ovs-tcpundump: Fix incompatibilities with python3 X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Added parenthesis after print and use "as" instead of "," in except. This commit fixes also a couple of flake8 warnings: utilities/ovs-tcpundump:23:1: E302 expected 2 blank lines, found 1 utilities/ovs-tcpundump:35:1: E305 expected 2 blank lines after class or function definition, found 1 Tested on Python 2.7.15 and Python 3.6.5 Signed-off-by: Timothy Redaelli --- utilities/ovs-tcpundump.in | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/utilities/ovs-tcpundump.in b/utilities/ovs-tcpundump.in index c99015b5b..c29870062 100755 --- a/utilities/ovs-tcpundump.in +++ b/utilities/ovs-tcpundump.in @@ -20,8 +20,9 @@ import sys argv0 = sys.argv[0] + def usage(): - print """\ + print("""\ %(argv0)s: print "tcpdump -xx" output as hex usage: %(argv0)s < FILE where FILE is output from "tcpdump -xx". @@ -29,14 +30,15 @@ where FILE is output from "tcpdump -xx". The following options are also available: -h, --help display this help message -V, --version display version information\ -""" % {'argv0': argv0} +""" % {'argv0': argv0}) sys.exit(0) + if __name__ == "__main__": try: options, args = getopt.gnu_getopt(sys.argv[1:], 'hV', ['help', 'version']) - except getopt.GetoptError, geo: + except getopt.GetoptError as geo: sys.stderr.write("%s: %s\n" % (argv0, geo.msg)) sys.exit(1) @@ -44,7 +46,7 @@ if __name__ == "__main__": if key in ['-h', '--help']: usage() elif key in ['-V', '--version']: - print "ovs-tcpundump (Open vSwitch) @VERSION@" + print("ovs-tcpundump (Open vSwitch) @VERSION@") else: sys.exit(0) @@ -63,12 +65,12 @@ if __name__ == "__main__": m = regex.match(line) if m is None or int(m.group(1), 16) == 0: if packet != '': - print packet + print(packet) packet = '' if m: packet += re.sub(r'\s', '', m.group(2), 0) if packet != '': - print packet + print(packet) # Local variables: # mode: python