You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/06/30 17:37:24 UTC

[35/50] [abbrv] git commit: SLIDER-153 revert rename -> slider.py for python

SLIDER-153 revert rename -> slider.py for python


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

Branch: refs/heads/feature/SLIDER-151_Implement_full_slider_API_in_REST_and_switch_client_to_it
Commit: 1c5f303f31693b89c1d767043655b16922ae0b57
Parents: 6f05995
Author: Steve Loughran <st...@apache.org>
Authored: Wed Jun 25 11:21:29 2014 -0700
Committer: Steve Loughran <st...@apache.org>
Committed: Wed Jun 25 11:21:29 2014 -0700

----------------------------------------------------------------------
 slider-assembly/src/main/scripts/slider    | 169 ------------------------
 slider-assembly/src/main/scripts/slider.py | 169 ++++++++++++++++++++++++
 2 files changed, 169 insertions(+), 169 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/1c5f303f/slider-assembly/src/main/scripts/slider
----------------------------------------------------------------------
diff --git a/slider-assembly/src/main/scripts/slider b/slider-assembly/src/main/scripts/slider
deleted file mode 100644
index d48eca6..0000000
--- a/slider-assembly/src/main/scripts/slider
+++ /dev/null
@@ -1,169 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# 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.
-import sys
-import os
-import subprocess
-
-CONF = "conf"
-
-LIB = "lib"
-
-SLIDER_CONF_DIR = "SLIDER_CONF_DIR"
-SLIDER_JVM_OPTS = "SLIDER_JVM_OPTS"
-SLIDER_CLASSPATH_EXTRA = "SLIDER_CLASSPATH_EXTRA"
-
-SLIDER_CLASSNAME = "org.apache.slider.Slider"
-DEFAULT_JVM__OPTS = "-Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Xmx256m -Djava.confdir=%s"
-
-"""
-Launches slider
-
-
-"""
-
-
-
-def scriptDir():
-  """ 
-  get the script path
-  """
-  return os.path.dirname(os.path.realpath(__file__))
-
-def sliderDir():
-  return os.path.dirname(scriptDir())
-
-def libDir(sliderdir) :
-  return os.path.join(sliderdir, LIB)
-
-def confDir(sliderdir):
-  """
-  determine the active configuration directory 
-  :param sliderdir: slider directory 
-  :return: the configuration directory -any env var will
-  override the relative path
-  """
-  localconf = os.path.join(sliderdir, CONF)
-  return os.environ.get(SLIDER_CONF_DIR,localconf) 
-
-def dirMustExist(dir):
-  if not os.path.exists(dir):
-    raise Exception("Directory does not exist: %s " % dir)
-  return dir
-
-def read(pipe, line):
-  """
-  read a char, append to the listing if there is a char that is not \n
-  :param pipe: pipe to read from 
-  :param line: line being built up
-  :return: (the potentially updated line, flag indicating newline reached)
-  """
-
-  c = pipe.read(1)
-  if c != "":
-    o = c.decode('utf-8')
-    if o != '\n':
-      line += o
-      return line, False
-    else:
-      return line, True
-  else:
-    return line, False
-    
-
-
-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))
-  confdir = dirMustExist(confDir(slider_home))
-  default_jvm_opts = DEFAULT_JVM__OPTS % confdir
-  slider_jvm_opts = os.environ.get(SLIDER_JVM_OPTS, default_jvm_opts)
-  # split the JVM opts by space
-  jvm_opts_split = slider_jvm_opts.split()
-  slider_classpath_extra = os.environ.get(SLIDER_CLASSPATH_EXTRA, "")
-  p = os.pathsep    # path separator
-  d = os.sep        # dir separator
-  slider_classpath = libdir + d + "*" + p \
-                     + confdir + p \
-                     + slider_classpath_extra 
-                     
-
-  print "slider_home = \"%s\"" % slider_home
-  print "slider_jvm_opts = \"%s\"" % slider_jvm_opts
-  print "slider_classpath = \"%s\"" % slider_classpath
-
-  #java = "/usr/bin/java"
-  commandline = ["java", ]
-  commandline.append("-classpath")
-  commandline.append(slider_classpath)
-  commandline.extend(jvm_opts_split)
-  commandline.append(SLIDER_CLASSNAME)
-  commandline.extend(args)
-  print "ready to exec : %s" % commandline
-  # docs warn of using PIPE on stderr 
-  exe = subprocess.Popen(commandline,
-                         stdin=None,
-                         stdout=subprocess.PIPE,
-                         stderr=subprocess.PIPE,
-                         shell=False)
-  stdout = exe.stdout
-  stderr = exe.stderr
-  outline = ""
-  errline = ""
-  while exe.poll() is None:
-    # process is running; grab output and echo every line
-    outline, done = read(stdout, outline)
-    if done:
-      print outline
-      outline = ""
-    errline, done = read(stderr, errline)
-    if done:
-      print errline
-      errline = ""
-
-  # get tail
-  out, err = exe.communicate()
-  print outline + out.decode()
-  print errline + err.decode()
-  return exe.returncode
-
-
-
-if __name__ == '__main__':
-  """
-  Entry point
-  """
-  try:
-    returncode = main()
-  except Exception as e:
-    print "Exception: %s " % e.message
-    returncode = -1
-  
-  sys.exit(returncode)

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/1c5f303f/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
new file mode 100644
index 0000000..d48eca6
--- /dev/null
+++ b/slider-assembly/src/main/scripts/slider.py
@@ -0,0 +1,169 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# 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.
+import sys
+import os
+import subprocess
+
+CONF = "conf"
+
+LIB = "lib"
+
+SLIDER_CONF_DIR = "SLIDER_CONF_DIR"
+SLIDER_JVM_OPTS = "SLIDER_JVM_OPTS"
+SLIDER_CLASSPATH_EXTRA = "SLIDER_CLASSPATH_EXTRA"
+
+SLIDER_CLASSNAME = "org.apache.slider.Slider"
+DEFAULT_JVM__OPTS = "-Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Xmx256m -Djava.confdir=%s"
+
+"""
+Launches slider
+
+
+"""
+
+
+
+def scriptDir():
+  """ 
+  get the script path
+  """
+  return os.path.dirname(os.path.realpath(__file__))
+
+def sliderDir():
+  return os.path.dirname(scriptDir())
+
+def libDir(sliderdir) :
+  return os.path.join(sliderdir, LIB)
+
+def confDir(sliderdir):
+  """
+  determine the active configuration directory 
+  :param sliderdir: slider directory 
+  :return: the configuration directory -any env var will
+  override the relative path
+  """
+  localconf = os.path.join(sliderdir, CONF)
+  return os.environ.get(SLIDER_CONF_DIR,localconf) 
+
+def dirMustExist(dir):
+  if not os.path.exists(dir):
+    raise Exception("Directory does not exist: %s " % dir)
+  return dir
+
+def read(pipe, line):
+  """
+  read a char, append to the listing if there is a char that is not \n
+  :param pipe: pipe to read from 
+  :param line: line being built up
+  :return: (the potentially updated line, flag indicating newline reached)
+  """
+
+  c = pipe.read(1)
+  if c != "":
+    o = c.decode('utf-8')
+    if o != '\n':
+      line += o
+      return line, False
+    else:
+      return line, True
+  else:
+    return line, False
+    
+
+
+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))
+  confdir = dirMustExist(confDir(slider_home))
+  default_jvm_opts = DEFAULT_JVM__OPTS % confdir
+  slider_jvm_opts = os.environ.get(SLIDER_JVM_OPTS, default_jvm_opts)
+  # split the JVM opts by space
+  jvm_opts_split = slider_jvm_opts.split()
+  slider_classpath_extra = os.environ.get(SLIDER_CLASSPATH_EXTRA, "")
+  p = os.pathsep    # path separator
+  d = os.sep        # dir separator
+  slider_classpath = libdir + d + "*" + p \
+                     + confdir + p \
+                     + slider_classpath_extra 
+                     
+
+  print "slider_home = \"%s\"" % slider_home
+  print "slider_jvm_opts = \"%s\"" % slider_jvm_opts
+  print "slider_classpath = \"%s\"" % slider_classpath
+
+  #java = "/usr/bin/java"
+  commandline = ["java", ]
+  commandline.append("-classpath")
+  commandline.append(slider_classpath)
+  commandline.extend(jvm_opts_split)
+  commandline.append(SLIDER_CLASSNAME)
+  commandline.extend(args)
+  print "ready to exec : %s" % commandline
+  # docs warn of using PIPE on stderr 
+  exe = subprocess.Popen(commandline,
+                         stdin=None,
+                         stdout=subprocess.PIPE,
+                         stderr=subprocess.PIPE,
+                         shell=False)
+  stdout = exe.stdout
+  stderr = exe.stderr
+  outline = ""
+  errline = ""
+  while exe.poll() is None:
+    # process is running; grab output and echo every line
+    outline, done = read(stdout, outline)
+    if done:
+      print outline
+      outline = ""
+    errline, done = read(stderr, errline)
+    if done:
+      print errline
+      errline = ""
+
+  # get tail
+  out, err = exe.communicate()
+  print outline + out.decode()
+  print errline + err.decode()
+  return exe.returncode
+
+
+
+if __name__ == '__main__':
+  """
+  Entry point
+  """
+  try:
+    returncode = main()
+  except Exception as e:
+    print "Exception: %s " % e.message
+    returncode = -1
+  
+  sys.exit(returncode)