Repository: spark
Updated Branches:
  refs/heads/branch-1.4 25b2f95fe -> 42070f096


[SPARK-7806][EC2] Fixes that allow the spark_ec2.py tool to run with Python3

I have used this script to launch, destroy, start, and stop clusters 
successfully.

Author: meawoppl <meawo...@gmail.com>

Closes #6336 from meawoppl/py3ec2spark and squashes the following commits:

2e87046 [meawoppl] Py3 compat fixes.

(cherry picked from commit 8dbe777703e0aaf47cbdfe98f66d22f723352fb5)
Signed-off-by: Davies Liu <dav...@databricks.com>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/42070f09
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/42070f09
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/42070f09

Branch: refs/heads/branch-1.4
Commit: 42070f096e8f8173e0f601100d408fcbe1ce2a12
Parents: 25b2f95
Author: meawoppl <meawo...@gmail.com>
Authored: Tue May 26 09:02:25 2015 -0700
Committer: Davies Liu <dav...@databricks.com>
Committed: Tue May 26 09:02:49 2015 -0700

----------------------------------------------------------------------
 ec2/spark_ec2.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/42070f09/ec2/spark_ec2.py
----------------------------------------------------------------------
diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py
index 4d1e748..2fab5c4 100755
--- a/ec2/spark_ec2.py
+++ b/ec2/spark_ec2.py
@@ -19,8 +19,9 @@
 # limitations under the License.
 #
 
-from __future__ import with_statement, print_function
+from __future__ import division, print_function, with_statement
 
+import codecs
 import hashlib
 import itertools
 import logging
@@ -47,6 +48,8 @@ if sys.version < "3":
 else:
     from urllib.request import urlopen, Request
     from urllib.error import HTTPError
+    raw_input = input
+    xrange = range
 
 SPARK_EC2_VERSION = "1.4.0"
 SPARK_EC2_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -424,13 +427,14 @@ def get_spark_ami(opts):
         b=opts.spark_ec2_git_branch)
 
     ami_path = "%s/%s/%s" % (ami_prefix, opts.region, instance_type)
+    reader = codecs.getreader("ascii")
     try:
-        ami = urlopen(ami_path).read().strip()
-        print("Spark AMI: " + ami)
+        ami = reader(urlopen(ami_path)).read().strip()
     except:
         print("Could not resolve AMI at: " + ami_path, file=stderr)
         sys.exit(1)
 
+    print("Spark AMI: " + ami)
     return ami
 
 
@@ -751,7 +755,7 @@ def setup_cluster(conn, master_nodes, slave_nodes, opts, 
deploy_ssh_key):
                'mapreduce', 'spark-standalone', 'tachyon']
 
     if opts.hadoop_major_version == "1":
-        modules = filter(lambda x: x != "mapreduce", modules)
+        modules = list(filter(lambda x: x != "mapreduce", modules))
 
     if opts.ganglia:
         modules.append('ganglia')
@@ -1157,7 +1161,7 @@ def get_zones(conn, opts):
 
 # Gets the number of items in a partition
 def get_partition(total, num_partitions, current_partitions):
-    num_slaves_this_zone = total / num_partitions
+    num_slaves_this_zone = total // num_partitions
     if (total % num_partitions) - current_partitions > 0:
         num_slaves_this_zone += 1
     return num_slaves_this_zone


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to