|
19 | 19 | # limitations under the License. |
20 | 20 | # |
21 | 21 |
|
22 | | -from __future__ import with_statement, print_function |
| 22 | +from __future__ import division, print_function, with_statement |
23 | 23 |
|
| 24 | +import codecs |
24 | 25 | import hashlib |
25 | 26 | import itertools |
26 | 27 | import logging |
|
47 | 48 | else: |
48 | 49 | from urllib.request import urlopen, Request |
49 | 50 | from urllib.error import HTTPError |
| 51 | + raw_input = input |
| 52 | + xrange = range |
50 | 53 |
|
51 | 54 | SPARK_EC2_VERSION = "1.3.1" |
52 | 55 | SPARK_EC2_DIR = os.path.dirname(os.path.realpath(__file__)) |
@@ -423,13 +426,14 @@ def get_spark_ami(opts): |
423 | 426 | b=opts.spark_ec2_git_branch) |
424 | 427 |
|
425 | 428 | ami_path = "%s/%s/%s" % (ami_prefix, opts.region, instance_type) |
| 429 | + reader = codecs.getreader("ascii") |
426 | 430 | try: |
427 | | - ami = urlopen(ami_path).read().strip() |
428 | | - print("Spark AMI: " + ami) |
| 431 | + ami = reader(urlopen(ami_path)).read().strip() |
429 | 432 | except: |
430 | 433 | print("Could not resolve AMI at: " + ami_path, file=stderr) |
431 | 434 | sys.exit(1) |
432 | 435 |
|
| 436 | + print("Spark AMI: " + ami) |
433 | 437 | return ami |
434 | 438 |
|
435 | 439 |
|
@@ -750,7 +754,7 @@ def setup_cluster(conn, master_nodes, slave_nodes, opts, deploy_ssh_key): |
750 | 754 | 'mapreduce', 'spark-standalone', 'tachyon'] |
751 | 755 |
|
752 | 756 | if opts.hadoop_major_version == "1": |
753 | | - modules = filter(lambda x: x != "mapreduce", modules) |
| 757 | + modules = list(filter(lambda x: x != "mapreduce", modules)) |
754 | 758 |
|
755 | 759 | if opts.ganglia: |
756 | 760 | modules.append('ganglia') |
@@ -1160,7 +1164,7 @@ def get_zones(conn, opts): |
1160 | 1164 |
|
1161 | 1165 | # Gets the number of items in a partition |
1162 | 1166 | def get_partition(total, num_partitions, current_partitions): |
1163 | | - num_slaves_this_zone = total / num_partitions |
| 1167 | + num_slaves_this_zone = total // num_partitions |
1164 | 1168 | if (total % num_partitions) - current_partitions > 0: |
1165 | 1169 | num_slaves_this_zone += 1 |
1166 | 1170 | return num_slaves_this_zone |
|
0 commit comments