Skip to content

Commit

Permalink
Merge pull request #2191 from cclauss/fix-xrange
Browse files Browse the repository at this point in the history
xrange() was removed in Python 3 in favor of range()
  • Loading branch information
k8s-ci-robot authored Jul 19, 2019
2 parents 53a577d + 00059ea commit 75d6701
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion hack/scripts/break_mig.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
import sys
import time

try:
range = xrange # Python 2
except NameError: # Python 3
pass


InstanceInfo = collections.namedtuple("InstanceInfo", 'name ip')

Expand Down Expand Up @@ -128,7 +133,7 @@ def clean_up(master, broken, verbose):
'''
if verbose:
print('Cleaning up top {} iptable rules'.format(len(broken)))
for i in xrange(len(broken)):
for i in range(len(broken)):
subprocess.call(['gcloud', 'compute', 'ssh', master, '--', 'sudo iptables -D INPUT 1'])


Expand Down
13 changes: 9 additions & 4 deletions hack/scripts/ca_metrics_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
import argparse
import json

try:
range = xrange # Python 2
except NameError: # Python 3
pass


class CAMetric(object):

Expand Down Expand Up @@ -59,7 +64,7 @@ def upper_bound(buckets):
Going from the rightmost bucket, find the first one that has some samples
and return its upper bound.
'''
for i in xrange(len(buckets) - 1, -1, -1):
for i in range(len(buckets) - 1, -1, -1):
le, count = buckets[i]
if i == 0:
return le
Expand All @@ -73,7 +78,7 @@ def parse_metrics_file(metrics_file):
'''
Return interesting metrics for all Cluster Autoscaler functions.
Metrics are stored in a map keyed by function name and are expressed in
Metrics are stored in a map keyed by function name and are expressed in
seconds. They include
* sum of all samples
* count of sumples
Expand Down Expand Up @@ -115,10 +120,10 @@ def main():
parser.add_argument('metrics_file', help='File to read metrics from')
args = parser.parse_args()

summary = parse_metrics_file(args.metrics_file)
summary = parse_metrics_file(args.metrics_file)
print_summary(summary)


if __name__ == '__main__':
main()

0 comments on commit 75d6701

Please sign in to comment.