From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 15BE868F7 for ; Sun, 30 Apr 2017 16:12:02 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id A260A20A88; Sun, 30 Apr 2017 10:12:02 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Sun, 30 Apr 2017 10:12:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=1YDgtDgz+icoYSEvoX5YETq0z7P Q5n4aSJl3Lz+uI7s=; b=cmbnUdCYFsmP98S3bGF9x0U2nB3McZeaiKsDY7cCU/Z SIKAoNit8A/tMGgDmn9z0B6+S2xpatD//cbaPcsz8VgNZGyNqMxLk640LPIzGR87 wCzo3Qvm8PkpkRyu4PhnXJfM1UszX78lgiRGWQTdAOn+FDPJuXcbewn6t8FUeQPw = DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=1YDgtD gz+icoYSEvoX5YETq0z7PQ5n4aSJl3Lz+uI7s=; b=VZTdhzKFx0CKZAs53pmsd8 nAoalRdQ/WZVR5g5JTpQmoeNNNSF9NWP2gKUvbbbAMzUEx8PewBdM7XNNVkalyy5 wauBbje5sHaZjOeSDiPPXW/g0m6eZm4syzfF9/5hbkVyLu4FmONMdJB1hQ7hezgT dIOgvmowoIqhrsXDkpfKRBOBFnphIQfR6+0FVGfb9FyQjlzBYFyy/PjqgkMr3odx KFoZfq8AX6F6Kj84FSnqXqo1xBAKXJmGL3XDH5P/V3AmZnpvtSSunIqEm4JWsoeR nfEIp9iUpcBdpyYlWhV1T4t6YzHC9fBhe8hcAHzpBhkwplj1TH09S65fqrp7xrlw == X-ME-Sender: X-Sasl-enc: BWtBcm5XY3MGyN6/sbjjCvTVN2YWzFDSllmseULmTJrW 1493561522 Received: from xps.monjalon.net (245.114.118.80.rev.sfr.net [80.118.114.245]) by mail.messagingengine.com (Postfix) with ESMTPA id 824847E766; Sun, 30 Apr 2017 10:12:01 -0400 (EDT) From: Thomas Monjalon To: Andriy Berestovskyy , Gowrishankar Muthukrishnan Cc: dev@dpdk.org Date: Sun, 30 Apr 2017 16:11:40 +0200 Message-Id: <20170430141140.7865-1-thomas@monjalon.net> X-Mailer: git-send-email 2.12.2 Subject: [dpdk-dev] [PATCH] usertools: fix CPU layout with python 3 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Apr 2017 14:12:03 -0000 These differences in Python 3 were causing errors: - xrange is replaced by range - dict values are a view (instead of list) - has_key is removed Fixes: deb87e6777c0 ("usertools: use sysfs for CPU layout") Fixes: 63985c5f104e ("usertools: fix CPU layout for more than 2 threads") Signed-off-by: Thomas Monjalon --- usertools/cpu_layout.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py index 99152a2ec..74da928df 100755 --- a/usertools/cpu_layout.py +++ b/usertools/cpu_layout.py @@ -35,6 +35,10 @@ # from __future__ import print_function import sys +try: + xrange # Python 2 +except NameError: + xrange = range # Python 3 sockets = [] cores = [] @@ -72,7 +76,7 @@ print("") max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1)) -max_thread_count = len(core_map.values()[0]) +max_thread_count = len(core_map) max_core_map_len = (max_processor_len * max_thread_count) \ + len(", ") * (max_thread_count - 1) \ + len('[]') + len('Socket ') @@ -92,7 +96,7 @@ for c in cores: output = "Core %s" % str(c).ljust(max_core_id_len) for s in sockets: - if core_map.has_key((s,c)): + if (s,c) in core_map: output += " " + str(core_map[(s, c)]).ljust(max_core_map_len) else: output += " " * (max_core_map_len + 1) -- 2.12.2