2013-07-16 20:21:33 -04:00
|
|
|
#
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership.
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
2012-10-19 20:16:41 -04:00
|
|
|
"""
|
|
|
|
An interactive shell.
|
|
|
|
|
2013-01-20 04:57:44 -05:00
|
|
|
This file is designed to be launched as a PYTHONSTARTUP script.
|
2013-01-02 00:25:49 -05:00
|
|
|
"""
|
|
|
|
import os
|
2013-01-30 18:04:06 -05:00
|
|
|
import pyspark
|
2012-10-19 20:16:41 -04:00
|
|
|
from pyspark.context import SparkContext
|
|
|
|
|
|
|
|
|
2013-01-02 00:25:49 -05:00
|
|
|
sc = SparkContext(os.environ.get("MASTER", "local"), "PySparkShell")
|
|
|
|
print "Spark context avaiable as sc."
|
2012-10-19 20:16:41 -04:00
|
|
|
|
2013-01-02 00:25:49 -05:00
|
|
|
# The ./pyspark script stores the old PYTHONSTARTUP value in OLD_PYTHONSTARTUP,
|
|
|
|
# which allows us to execute the user's PYTHONSTARTUP file:
|
|
|
|
_pythonstartup = os.environ.get('OLD_PYTHONSTARTUP')
|
|
|
|
if _pythonstartup and os.path.isfile(_pythonstartup):
|
2013-01-20 04:57:44 -05:00
|
|
|
execfile(_pythonstartup)
|