From 7cd4bf4c76c53ebaf0deba14ffde5ef5065d52ca Mon Sep 17 00:00:00 2001 From: zhangyangyang Date: Sat, 1 Sep 2018 17:34:05 +0800 Subject: [PATCH] Python 3 compatibility: fix xrange/range issues xrange is not defined in python3. Rename xrange() to range(). Story: 2002909 Task: 24567 Change-Id: I1cf9b77339fee79fd4750ca873a952a39974c23c Signed-off-by: zhangyangyang --- .../vm-topology/vm_topology/exec/vm_topology.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/vm-topology/vm-topology/vm_topology/exec/vm_topology.py b/tools/vm-topology/vm-topology/vm_topology/exec/vm_topology.py index 3dbb32a7b..011900bce 100644 --- a/tools/vm-topology/vm-topology/vm_topology/exec/vm_topology.py +++ b/tools/vm-topology/vm-topology/vm_topology/exec/vm_topology.py @@ -444,7 +444,7 @@ def _mask_to_cpulist(mask=0): # Assume max number of cpus for now... max_cpus = 128 - for cpu in xrange(max_cpus): + for cpu in range(max_cpus): if ((1 << cpu) & mask): cpulist.append(cpu) return cpulist @@ -492,9 +492,9 @@ def range_to_list(csv_range=None): """ if not csv_range: return [] - xranges = [(lambda L: xrange(L[0], L[-1] + 1))(map(int, r.split('-'))) + ranges = [(lambda L: range(L[0], L[-1] + 1))(map(int, r.split('-'))) for r in csv_range.split(',')] - return [y for x in xranges for y in x] + return [y for x in ranges for y in x] class TimeoutError(Exception): @@ -613,7 +613,7 @@ def do_libvirt_domain_info((host)): cpulist_d = {} cpuset_total = 0 up_total = 0 - for vcpu in xrange(d_nrVirtCpu): + for vcpu in range(d_nrVirtCpu): cpuset_b = d_vcpus[1][vcpu] cpuset = 0 for cpu, up in enumerate(cpuset_b):