From d788cc59b1cd4278ca0b8b2d9f6fe93f80550af3 Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Tue, 5 Jun 2018 09:49:23 -0400 Subject: core/various: python3 compat, prepare for python2 -> python3 see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, https://review.gluster.org/#/c/19952/, and https://review.gluster.org/#/c/20104/ This patch changes uses of xrange() to range(), as suggested by the python 2to3 utility. https://www.geeksforgeeks.org/range-vs-xrange-python/ In Python 3, there is no xrange , but the range function behaves like xrange in Python 2. (My concern is that range() in python2 may behave differently until we "throw the switch" to switch to python3.) Note: Fedora packaging guidelines require explicit shebangs, so popular practices like #!/usr/bin/env python and #!/usr/bin/python are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3 Note: Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, idioms, numliterals, set_literal, types, urllib, and zip have already been applied. Also version agnostic imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1 Note: these 2to3 fixes report no changes are necessary: asserts, buffer, exec, execfile, exitfunc, filter, getcwdu, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Change-Id: I16ae9f4e3a4fd02a0623fb6f9fdb7aaf65f2a8a9 updates: #411 Signed-off-by: Kaleb S. KEITHLEY --- extras/failed-tests.py | 2 +- extras/rebalance.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'extras') diff --git a/extras/failed-tests.py b/extras/failed-tests.py index 1ef1a954f4f..54406f91ad3 100755 --- a/extras/failed-tests.py +++ b/extras/failed-tests.py @@ -98,7 +98,7 @@ def get_summary(cut_off_date, reg_link): ''' success_count = 0 failure_count = 0 - for page in xrange(0, MAX_BUILDS, 100): + for page in range(0, MAX_BUILDS, 100): build_info = requests.get(''.join([ BASE, reg_link, diff --git a/extras/rebalance.py b/extras/rebalance.py index 69ce282b39e..871b06682d5 100755 --- a/extras/rebalance.py +++ b/extras/rebalance.py @@ -263,7 +263,7 @@ if __name__ == "__main__": while used < len(bricks): best_place = used best_score = get_score(bricks) - for i in xrange(used): + for i in range(used): new_bricks = bricks[:] del new_bricks[used] new_bricks.insert(i,bricks[used]) -- cgit