You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by sm...@apache.org on 2014/10/31 00:30:43 UTC

git commit: SLIDER-526. Create a python wrapper and replace the shell script for slider (Thomas Liu via smohanty)

Repository: incubator-slider
Updated Branches:
  refs/heads/develop fdcc5c2cf -> d03bf28e8


SLIDER-526. Create a python wrapper and replace the shell script for slider (Thomas Liu via smohanty)


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/d03bf28e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/d03bf28e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/d03bf28e

Branch: refs/heads/develop
Commit: d03bf28e84b155332f4b78ff3ff412c9982d2ef4
Parents: fdcc5c2
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Thu Oct 30 16:30:31 2014 -0700
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Thu Oct 30 16:30:31 2014 -0700

----------------------------------------------------------------------
 slider-assembly/src/main/scripts/slider    | 84 ++++---------------------
 slider-assembly/src/main/scripts/slider.py |  8 ---
 2 files changed, 13 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/d03bf28e/slider-assembly/src/main/scripts/slider
----------------------------------------------------------------------
diff --git a/slider-assembly/src/main/scripts/slider b/slider-assembly/src/main/scripts/slider
index 51ec060..9646694 100755
--- a/slider-assembly/src/main/scripts/slider
+++ b/slider-assembly/src/main/scripts/slider
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env python
 
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -16,78 +16,20 @@
 # limitations under the License.
 
 
-# this is the shell script to start Slider deploying an application
+# this is the wrapper shell script to invoke the Slider.py script in the same folder
 # Usage: slider <action> <commands>
 
-# The env variable SLIDER_JVM_OPTS can be used to override
-# the default JVM opts
+import os
+import sys
+import subprocess
 
-function usage
-{
-  echo "Usage: slider <action> <arguments>"
-  echo ""
-}
+ON_POSIX = 'posix' in sys.builtin_module_names
 
-# Slider works out its own location 
-this="${BASH_SOURCE-$0}"
-bindir=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
-script="$(basename -- "$this")"
+currDir = os.path.dirname(os.path.realpath(__file__))
+args = sys.argv[1:]
+cmd = [currDir + "/slider.py"]
+cmd.extend(args)
+finalCmd = " ".join(cmd)
 
-# lib directory is one up; it is expected to contain 
-# slider.jar and any other dependencies that are not in the
-# standard Hadoop classpath
-
-slider_home="${bindir}/.."
-slider_home=`cd -P "${slider_home}" && pwd -P`
-
-libdir="${slider_home}/lib"
-libdir=`cd -P "${libdir}" && pwd -P`
-
-
-confdir="${slider_home}/conf"
-
-# normalize the conf dir so it can be passed down
-confdir=`cd -P "${confdir}" && pwd -P`
-confdir=${SLIDER_CONF_DIR:-$confdir}
-
-
-if [ -f "${confdir}/slider-env.sh" ]; then
-  . "${confdir}/slider-env.sh"
-fi
-
-slider_confdir_opts="-Dslider.confdir=${confdir}"
-libdir_jvm_opts="-Dslider.libdir=${libdir}"
-
-slider_jvm_opts="-Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Xmx256m"
-slider_jvm_opts=${SLIDER_JVM_OPTS:-$slider_jvm_opts}
-
-# allow for an extra classpath
-slider_classpath_extra=${SLIDER_CLASSPATH_EXTRA:-""}
-hadoop_conf_dir=${HADOOP_CONF_DIR:-""}
-
-slider_classpath="${libdir}/*:${confdir}:${slider_classpath_extra}:${hadoop_conf_dir}"
-
-launcher=org.apache.slider.Slider
-
-export CLASSPATH="${slider_classpath}"
-
-#echo "slider_home = \"${slider_home}\""
-#echo "slider_jvm_opts = \"${slider_jvm_opts}\""
-#echo "classpath = \"${slider_classpath}\""
-#echo ""
-
-#echo "command is java ${slider_jvm_opts} -classpath \"${slider_classpath}\" ${launcher} $@"
-
-#echo ""
-#echo ""
-
-if [ -n "${JAVA_HOME}" ]; then
-  javabin=${JAVA_HOME}/bin/
-else
-  javabin=""
-fi
-
-#echo $javabin
-#type ${javabin}java 2>&1
-
-exec ${javabin}java ${slider_jvm_opts} ${slider_confdir_opts} ${libdir_jvm_opts} ${launcher} $@
+result = subprocess.call(finalCmd, shell=True)
+sys.exit(result)

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/d03bf28e/slider-assembly/src/main/scripts/slider.py
----------------------------------------------------------------------
diff --git a/slider-assembly/src/main/scripts/slider.py b/slider-assembly/src/main/scripts/slider.py
index 02b0355..26c9adc 100644
--- a/slider-assembly/src/main/scripts/slider.py
+++ b/slider-assembly/src/main/scripts/slider.py
@@ -261,19 +261,11 @@ def java(classname, args, classpath, jvm_opts_list):
   return runProcess(commandline)
 
 
-def usage():
-  print "Usage: slider <action> <arguments>"
-  return 1
-
-
 def main():
   """
   Slider main method
   :return: exit code of the process
   """
-  if len(sys.argv)==1 :
-    return usage()
-  # print "stdout encoding: "+ sys.stdout.encoding
   args = sys.argv[1:]
   slider_home = sliderDir()
   libdir = dirMustExist(libDir(slider_home))