aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/shell.py
diff options
context:
space:
mode:
authorJosh Rosen <joshrosen@eecs.berkeley.edu>2013-01-01 14:48:45 -0800
committerJosh Rosen <joshrosen@eecs.berkeley.edu>2013-01-01 15:05:00 -0800
commitb58340dbd9a741331fc4c3829b08c093560056c2 (patch)
tree52b0e94c47892a8f884b2f80a59ccdb1a428b389 /python/pyspark/shell.py
parent170e451fbdd308ae77065bd9c0f2bd278abf0cb7 (diff)
downloadspark-b58340dbd9a741331fc4c3829b08c093560056c2.tar.gz
spark-b58340dbd9a741331fc4c3829b08c093560056c2.tar.bz2
spark-b58340dbd9a741331fc4c3829b08c093560056c2.zip
Rename top-level 'pyspark' directory to 'python'
Diffstat (limited to 'python/pyspark/shell.py')
-rw-r--r--python/pyspark/shell.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/python/pyspark/shell.py b/python/pyspark/shell.py
new file mode 100644
index 0000000000..bd39b0283f
--- /dev/null
+++ b/python/pyspark/shell.py
@@ -0,0 +1,33 @@
+"""
+An interactive shell.
+"""
+import optparse # I prefer argparse, but it's not included with Python < 2.7
+import code
+import sys
+
+from pyspark.context import SparkContext
+
+
+def main(master='local', ipython=False):
+ sc = SparkContext(master, 'PySparkShell')
+ user_ns = {'sc' : sc}
+ banner = "Spark context avaiable as sc."
+ if ipython:
+ import IPython
+ IPython.embed(user_ns=user_ns, banner2=banner)
+ else:
+ print banner
+ code.interact(local=user_ns)
+
+
+if __name__ == '__main__':
+ usage = "usage: %prog [options] master"
+ parser = optparse.OptionParser(usage=usage)
+ parser.add_option("-i", "--ipython", help="Run IPython shell",
+ action="store_true")
+ (options, args) = parser.parse_args()
+ if len(sys.argv) > 1:
+ master = args[0]
+ else:
+ master = 'local'
+ main(master, options.ipython)