From 55d1b0531a0b322a1b851fc921fd6fdf25d26331 Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Mon, 2 Jul 2018 08:18:54 -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/, https://review.gluster.org/#/c/20104/, https://review.gluster.org/#/c/20162/, https://review.gluster.org/#/c/20185/, https://review.gluster.org/#/c/20207/, https://review.gluster.org/#/c/20227/, https://review.gluster.org/#/c/20307/, https://review.gluster.org/#/c/20320/, https://review.gluster.org/#/c/20332/, and https://review.gluster.org/#/c/20364/ Fixes glupy.py python2isms, iteritems -> items, and some overlooked print() in georep/peer_mountbroker.in Note: Fedora packaging guidelines and SUSE rpmlint require explicit shebangs; 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, has_key, idioms, map, numliterals, raise, 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, imports2, input, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Change-Id: Idda031c1ec975417c79323aea33e7b694e752b2a updates: #411 Signed-off-by: Kaleb S. KEITHLEY --- extras/create_new_xlator/generate_xlator.py | 2 +- extras/failed-tests.py | 2 +- extras/git-branch-diff.py | 4 ++-- extras/prot_filter.py | 2 +- extras/rebalance.py | 2 +- extras/volfilter.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'extras') diff --git a/extras/create_new_xlator/generate_xlator.py b/extras/create_new_xlator/generate_xlator.py index 0a54089080c..67e2e9c6e17 100755 --- a/extras/create_new_xlator/generate_xlator.py +++ b/extras/create_new_xlator/generate_xlator.py @@ -67,7 +67,7 @@ def generate(tmpl, name, table): sdict["@RET_TYPE@"] = string.join(ret_type, "") sdict["@RET_VAR@"] = string.join(ret_var, "") - for old, new in sdict.iteritems(): + for old, new in sdict.items(): tmpl = tmpl.replace(old, new) # TBD: reindent/reformat the result for maximum readability. return tmpl diff --git a/extras/failed-tests.py b/extras/failed-tests.py index 54406f91ad3..0f5ad38aa09 100755 --- a/extras/failed-tests.py +++ b/extras/failed-tests.py @@ -74,7 +74,7 @@ def print_summary(failed_builds, total_builds, html=False): count[template], {'failed': failed_builds, 'total': total_builds} )) - for k, v in summary.iteritems(): + for k, v in summary.items(): if k == 'core': print(''.join([TERM.red, "Found cores:", TERM.normal])) for comp, link in zip(v[::2], v[1::2]): diff --git a/extras/git-branch-diff.py b/extras/git-branch-diff.py index 99cc707b837..3c29e35bd7b 100755 --- a/extras/git-branch-diff.py +++ b/extras/git-branch-diff.py @@ -217,7 +217,7 @@ class GitBranchDiff: print(self.tick + " Successfully Backported changes:") print(' {' + 'from: ' + self.s_pattern + \ ' to: '+ self.t_pattern + '}\n') - for key, value in self.s_dict.iteritems(): + for key, value in self.s_dict.items(): if value in self.t_dict.itervalues(): print("[%s%s%s] %s" %(self.yello_set, key, @@ -231,7 +231,7 @@ class GitBranchDiff: else: review_list = [] - for key, value in self.s_dict.iteritems(): + for key, value in self.s_dict.items(): if value not in self.t_dict.itervalues(): if any(value in s for s in review_list): print("[%s%s%s] %s %s(under review)%s" %(self.yello_set, diff --git a/extras/prot_filter.py b/extras/prot_filter.py index e2b81218f40..3baa27c3f6d 100755 --- a/extras/prot_filter.py +++ b/extras/prot_filter.py @@ -91,7 +91,7 @@ def generate (graph, last, stream=sys.stdout): sv.dumped = True print("volume %s" % last.name, file=stream) print(" type %s" % last.xl_type, file=stream) - for k, v in last.opts.iteritems(): + for k, v in last.opts.items(): print(" option %s %s" % (k, v), file=stream) if last.subvols: print(" subvolumes %s" % string.join( diff --git a/extras/rebalance.py b/extras/rebalance.py index 32ca067b32d..0023f9970a8 100755 --- a/extras/rebalance.py +++ b/extras/rebalance.py @@ -49,7 +49,7 @@ def generate_stanza (vf, all_xlators, cur_subvol): sv_list.append(sv.name) vf.write("volume %s\n"%cur_subvol.name) vf.write(" type %s\n"%cur_subvol.type) - for kvpair in cur_subvol.opts.iteritems(): + for kvpair in cur_subvol.opts.items(): vf.write(" option %s %s\n"%kvpair) if sv_list: vf.write(" subvolumes %s\n"%string.join(sv_list)) diff --git a/extras/volfilter.py b/extras/volfilter.py index da0a0e62ddb..ea4bf22a440 100644 --- a/extras/volfilter.py +++ b/extras/volfilter.py @@ -132,7 +132,7 @@ def generate (graph, last, stream=sys.stdout): sv.dumped = True print("volume %s" % last.name, file=stream) print(" type %s" % last.type, file=stream) - for k, v in last.opts.iteritems(): + for k, v in last.opts.items(): print(" option %s %s" % (k, v), file=stream) if last.subvols: print(" subvolumes %s" % string.join( -- cgit