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/24 22:21:13 UTC
[1/4] git commit: SLIDER-153 python script working: stdout and stderr
is being printed after the end of the process
Repository: incubator-slider
Updated Branches:
refs/heads/feature/SLIDER-153_add_slider_py_command acdfe5bd6 -> 8a8ffd94c
SLIDER-153 python script working: stdout and stderr is being printed after the end of the process
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/06816c4c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/06816c4c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/06816c4c
Branch: refs/heads/feature/SLIDER-153_add_slider_py_command
Commit: 06816c4cd6ffbb94014ff95250f26c5028723a09
Parents: acdfe5b
Author: Steve Loughran <st...@apache.org>
Authored: Tue Jun 24 10:52:10 2014 -0700
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Jun 24 10:52:10 2014 -0700
----------------------------------------------------------------------
slider-assembly/src/main/scripts/slider.py | 28 ++++++++++++++++---------
1 file changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/06816c4c/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 2c1f4b3..cfad59a 100644
--- a/slider-assembly/src/main/scripts/slider.py
+++ b/slider-assembly/src/main/scripts/slider.py
@@ -97,21 +97,27 @@ def main():
print "slider_home = \"%s\"" % slider_home
print "slider_jvm_opts = \"%s\"" % slider_jvm_opts
print "slider_classpath = \"%s\"" % slider_classpath
-
-
- commandline = ["java",]
+
+ #java = "/usr/bin/java"
+ java = "java"
+ commandline = [java,
+ "-classpath",
+ slider_classpath,
+ SLIDER_CLASSNAME]
# commandline.append(slider_jvm_opts)
- commandline.append("-classpath")
- commandline.append(slider_classpath)
- commandline.append(SLIDER_CLASSNAME)
commandline.extend(args)
print "ready to exec : %s" % commandline
# docs warn of using PIPE on stderr
- return subprocess.call(commandline,
- stdin=None,
+ exe = subprocess.Popen(commandline,
+ stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
+ stderr=subprocess.PIPE,
shell=False)
+ exe.wait()
+ out, err = exe.communicate()
+ print "stdout : ", out.decode()
+ print "stderr : ", err.decode()
+ return exe.returncode
@@ -122,7 +128,9 @@ if __name__ == '__main__':
try:
rv = main()
if rv != 0:
- print "exit code = %d" % rv
+ print "Failed with exit code = %d" % rv
+ else:
+ print "Success"
except Exception as e:
print "Exception: %s " % e.message
rv = -1
[4/4] git commit: SLIDER-153 add JVM args to CLI
Posted by st...@apache.org.
SLIDER-153 add JVM args to CLI
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/8a8ffd94
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/8a8ffd94
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/8a8ffd94
Branch: refs/heads/feature/SLIDER-153_add_slider_py_command
Commit: 8a8ffd94c9b9685df578ba493e6cb0148af0e5b1
Parents: 77f3e02
Author: Steve Loughran <st...@apache.org>
Authored: Tue Jun 24 13:19:49 2014 -0700
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Jun 24 13:19:49 2014 -0700
----------------------------------------------------------------------
slider-assembly/src/main/scripts/slider.py | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8a8ffd94/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 77c39aa..d48eca6 100644
--- a/slider-assembly/src/main/scripts/slider.py
+++ b/slider-assembly/src/main/scripts/slider.py
@@ -30,14 +30,12 @@ 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
-
-
"""
+Launches slider
+"""
-print os.environ['HOME']
def scriptDir():
@@ -107,6 +105,8 @@ def main():
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
@@ -120,12 +120,11 @@ def main():
print "slider_classpath = \"%s\"" % slider_classpath
#java = "/usr/bin/java"
- java = "java"
- commandline = [java,
- "-classpath",
- slider_classpath,
- SLIDER_CLASSNAME]
- # commandline.append(slider_jvm_opts)
+ 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
[2/4] git commit: SLIDER-153: output streaming now working
Posted by st...@apache.org.
SLIDER-153: output streaming now working
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/6fc569de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/6fc569de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/6fc569de
Branch: refs/heads/feature/SLIDER-153_add_slider_py_command
Commit: 6fc569de084dbba6a9701bba5595f557d1029484
Parents: 06816c4
Author: Steve Loughran <st...@apache.org>
Authored: Tue Jun 24 13:01:37 2014 -0700
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Jun 24 13:01:37 2014 -0700
----------------------------------------------------------------------
slider-assembly/src/main/scripts/slider.py | 60 +++++++++++++++++++------
1 file changed, 46 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/6fc569de/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 cfad59a..1e55cc6 100644
--- a/slider-assembly/src/main/scripts/slider.py
+++ b/slider-assembly/src/main/scripts/slider.py
@@ -67,6 +67,26 @@ def dirMustExist(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>"
@@ -80,6 +100,7 @@ def main():
"""
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))
@@ -109,30 +130,41 @@ def main():
print "ready to exec : %s" % commandline
# docs warn of using PIPE on stderr
exe = subprocess.Popen(commandline,
- stdin=subprocess.PIPE,
+ stdin=None,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=False)
- exe.wait()
+ 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 "stdout : ", out.decode()
- print "stderr : ", err.decode()
+ print outline + out.decode()
+ print errline + err.decode()
return exe.returncode
-
-
if __name__ == '__main__':
- print "slider python script"
+ """
+ Entry point
+ """
try:
- rv = main()
- if rv != 0:
- print "Failed with exit code = %d" % rv
- else:
- print "Success"
+ returncode = main()
except Exception as e:
print "Exception: %s " % e.message
- rv = -1
+ returncode = -1
- sys.exit(rv)
+ sys.exit(returncode)
[3/4] git commit: SLIDER-153 fix shebang line
Posted by st...@apache.org.
SLIDER-153 fix shebang line
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/77f3e021
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/77f3e021
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/77f3e021
Branch: refs/heads/feature/SLIDER-153_add_slider_py_command
Commit: 77f3e02186cf1e55857eb991c216e94ef4f85c49
Parents: 6fc569d
Author: Steve Loughran <st...@apache.org>
Authored: Tue Jun 24 13:18:50 2014 -0700
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Jun 24 13:18:50 2014 -0700
----------------------------------------------------------------------
slider-assembly/src/main/scripts/slider.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/77f3e021/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 1e55cc6..77c39aa 100644
--- a/slider-assembly/src/main/scripts/slider.py
+++ b/slider-assembly/src/main/scripts/slider.py
@@ -1,4 +1,4 @@
-# !/usr/bin/env python
+#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Licensed to the Apache Software Foundation (ASF) under one or more