You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2014/06/26 23:09:47 UTC

[1/5] git commit: STORM-365: Add support for Python 3 to the storm command

Repository: incubator-storm
Updated Branches:
  refs/heads/master 6f57464c5 -> b659979a1


STORM-365: Add support for Python 3 to the storm command

This patch makes the storm command work with both Python 2 and Python 3.


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

Branch: refs/heads/master
Commit: 5ca09df570a186aaf99a4e33765d75f976a44556
Parents: 5c82b9f
Author: Muneyuki Noguchi <no...@gmail.com>
Authored: Sun Jun 22 20:24:50 2014 +0900
Committer: Muneyuki Noguchi <no...@gmail.com>
Committed: Sun Jun 22 21:30:45 2014 +0900

----------------------------------------------------------------------
 bin/storm | 59 +++++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 36 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/5ca09df5/bin/storm
----------------------------------------------------------------------
diff --git a/bin/storm b/bin/storm
index 2c72679..42be37b 100755
--- a/bin/storm
+++ b/bin/storm
@@ -22,8 +22,18 @@ import random
 import subprocess as sub
 import re
 import shlex
-import urllib
-import ConfigParser
+try:
+    # python 3
+    from urllib.parse import quote_plus
+except ImportError:
+    # python 2
+    from urllib import quote_plus
+try:
+    # python 3
+    import configparser
+except ImportError:
+    # python 2
+    import ConfigParser as configparser
 
 def identity(x):
     return x
@@ -40,7 +50,7 @@ def init_storm_env():
     ini_file = os.path.join(CLUSTER_CONF_DIR, 'storm_env.ini')
     if not os.path.isfile(ini_file):
         return
-    config = ConfigParser.ConfigParser()
+    config = configparser.ConfigParser()
     config.optionxform = str
     config.read(ini_file)
     options = config.options('environment')
@@ -71,13 +81,13 @@ JAVA_CMD = 'java' if not JAVA_HOME else os.path.join(JAVA_HOME, 'bin', 'java')
 
 def get_config_opts():
     global CONFIG_OPTS
-    return "-Dstorm.options=" + ','.join(map(urllib.quote_plus,CONFIG_OPTS))
+    return "-Dstorm.options=" + ','.join(map(quote_plus,CONFIG_OPTS))
 
 if not os.path.exists(STORM_DIR + "/RELEASE"):
-    print "******************************************"
-    print "The storm client can only be run from within a release. You appear to be trying to run the client from a checkout of Storm's source code."
-    print "\nYou can download a Storm release at http://storm-project.net/downloads.html"
-    print "******************************************"
+    print("******************************************")
+    print("The storm client can only be run from within a release. You appear to be trying to run the client from a checkout of Storm's source code.")
+    print("\nYou can download a Storm release at http://storm-project.net/downloads.html")
+    print("******************************************")
     sys.exit(1)  
 
 def get_jars_full(adir):
@@ -102,6 +112,9 @@ def confvalue(name, extrapaths):
     ]
     p = sub.Popen(command, stdout=sub.PIPE)
     output, errors = p.communicate()
+    # python 3
+    if not isinstance(output, str):
+        output = output.decode('utf-8')
     lines = output.split("\n")
     for line in lines:
         tokens = line.split(" ")
@@ -116,7 +129,7 @@ def print_localconfvalue(name):
     The local Storm configs are the ones in ~/.storm/storm.yaml merged 
     in with the configs in defaults.yaml.
     """
-    print name + ": " + confvalue(name, [USER_CONF_DIR])
+    print(name + ": " + confvalue(name, [USER_CONF_DIR]))
 
 def print_remoteconfvalue(name):
     """Syntax: [storm remoteconfvalue conf-name]
@@ -127,7 +140,7 @@ def print_remoteconfvalue(name):
 
     This command must be run on a cluster machine.
     """
-    print name + ": " + confvalue(name, [CLUSTER_CONF_DIR])
+    print(name + ": " + confvalue(name, [CLUSTER_CONF_DIR]))
 
 def parse_args(string):
     r"""Takes a string of whitespace-separated tokens and parses it into a list.
@@ -157,7 +170,7 @@ def exec_storm_class(klass, jvmtype="-server", jvmopts=[], extrajars=[], args=[]
         "-Dstorm.conf.file=" + CONFFILE,
         "-cp", get_classpath(extrajars),
     ] + jvmopts + [klass] + list(args)
-    print "Running: " + " ".join(all_args)
+    print("Running: " + " ".join(all_args))
     if fork:
         os.spawnvp(os.P_WAIT, JAVA_CMD, all_args)
     else:
@@ -400,37 +413,37 @@ def version():
   """
   releasefile = STORM_DIR + "/RELEASE"
   if os.path.exists(releasefile):
-    print open(releasefile).readline().strip()
+    print(open(releasefile).readline().strip())
   else:
-    print "Unknown"
+    print("Unknown")
 
 def print_classpath():
     """Syntax: [storm classpath]
 
     Prints the classpath used by the storm client when running commands.
     """
-    print get_classpath([])
+    print(get_classpath([]))
 
 def print_commands():
     """Print all client commands and link to documentation"""
-    print "Commands:\n\t",  "\n\t".join(sorted(COMMANDS.keys()))
-    print "\nHelp:", "\n\thelp", "\n\thelp <command>"
-    print "\nDocumentation for the storm client can be found at http://storm.incubator.apache.org/documentation/Command-line-client.html\n"
-    print "Configs can be overridden using one or more -c flags, e.g. \"storm list -c nimbus.host=nimbus.mycompany.com\"\n"
+    print("Commands:\n\t " +  "\n\t".join(sorted(COMMANDS.keys())))
+    print("\nHelp: \n\thelp \n\thelp <command>")
+    print("\nDocumentation for the storm client can be found at http://storm.incubator.apache.org/documentation/Command-line-client.html\n")
+    print("Configs can be overridden using one or more -c flags, e.g. \"storm list -c nimbus.host=nimbus.mycompany.com\"\n")
 
 def print_usage(command=None):
     """Print one help message or list of available commands"""
     if command != None:
-        if COMMANDS.has_key(command):
-            print (COMMANDS[command].__doc__ or 
-                  "No documentation provided for <%s>" % command)
+        if command in COMMANDS:
+            print((COMMANDS[command].__doc__ or 
+                  "No documentation provided for <%s>" % command))
         else:
-           print "<%s> is not a valid command" % command
+           print("<%s> is not a valid command" % command)
     else:
         print_commands()
 
 def unknown_command(*args):
-    print "Unknown command: [storm %s]" % ' '.join(sys.argv[1:])
+    print("Unknown command: [storm %s]" % ' '.join(sys.argv[1:]))
     print_usage()
 
 COMMANDS = {"jar": jar, "kill": kill, "shell": shell, "nimbus": nimbus, "ui": ui, "logviewer": logviewer,


[3/5] git commit: Fix the output of `storm help`.

Posted by bo...@apache.org.
Fix the output of `storm help`.


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

Branch: refs/heads/master
Commit: a90a285f768844eb48c96b2de60a0f570230c001
Parents: ae816ac
Author: Muneyuki Noguchi <no...@gmail.com>
Authored: Sun Jun 22 23:38:14 2014 +0900
Committer: Muneyuki Noguchi <no...@gmail.com>
Committed: Sun Jun 22 23:39:47 2014 +0900

----------------------------------------------------------------------
 bin/storm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/a90a285f/bin/storm
----------------------------------------------------------------------
diff --git a/bin/storm b/bin/storm
index 7751b77..2cdf2be 100755
--- a/bin/storm
+++ b/bin/storm
@@ -426,7 +426,7 @@ def print_classpath():
 
 def print_commands():
     """Print all client commands and link to documentation"""
-    print("Commands:\n\t " +  "\n\t".join(sorted(COMMANDS.keys())))
+    print("Commands:\n\t" +  "\n\t".join(sorted(COMMANDS.keys())))
     print("\nHelp: \n\thelp \n\thelp <command>")
     print("\nDocumentation for the storm client can be found at http://storm.incubator.apache.org/documentation/Command-line-client.html\n")
     print("Configs can be overridden using one or more -c flags, e.g. \"storm list -c nimbus.host=nimbus.mycompany.com\"\n")


[2/5] git commit: Remove redundant parentheses.

Posted by bo...@apache.org.
Remove redundant parentheses.


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

Branch: refs/heads/master
Commit: ae816ac7b13e1d41a54ca82854553cfabd6f94a5
Parents: 5ca09df
Author: Muneyuki Noguchi <no...@gmail.com>
Authored: Sun Jun 22 23:29:21 2014 +0900
Committer: Muneyuki Noguchi <no...@gmail.com>
Committed: Sun Jun 22 23:39:44 2014 +0900

----------------------------------------------------------------------
 bin/storm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/ae816ac7/bin/storm
----------------------------------------------------------------------
diff --git a/bin/storm b/bin/storm
index 42be37b..7751b77 100755
--- a/bin/storm
+++ b/bin/storm
@@ -435,8 +435,8 @@ def print_usage(command=None):
     """Print one help message or list of available commands"""
     if command != None:
         if command in COMMANDS:
-            print((COMMANDS[command].__doc__ or 
-                  "No documentation provided for <%s>" % command))
+            print(COMMANDS[command].__doc__ or
+                  "No documentation provided for <%s>" % command)
         else:
            print("<%s> is not a valid command" % command)
     else:


[4/5] git commit: Merge branch 'storm-command-python3' of https://github.com/mnogu/incubator-storm into STORM-365

Posted by bo...@apache.org.
Merge branch 'storm-command-python3' of https://github.com/mnogu/incubator-storm into STORM-365

STORM-365: Add support for Python 3 to storm command.


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

Branch: refs/heads/master
Commit: e3c93445eb112c90ad3d4ca961416a8b26c43a3c
Parents: 6f57464 a90a285
Author: Robert (Bobby) Evans <bo...@apache.org>
Authored: Thu Jun 26 16:07:42 2014 -0500
Committer: Robert (Bobby) Evans <bo...@apache.org>
Committed: Thu Jun 26 16:07:42 2014 -0500

----------------------------------------------------------------------
 bin/storm | 57 +++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 35 insertions(+), 22 deletions(-)
----------------------------------------------------------------------



[5/5] git commit: Added STORM-365 to Changelog

Posted by bo...@apache.org.
Added STORM-365 to Changelog


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

Branch: refs/heads/master
Commit: b659979a1526c4eb1461981de9f8f512317d3eba
Parents: e3c9344
Author: Robert (Bobby) Evans <bo...@apache.org>
Authored: Thu Jun 26 16:08:59 2014 -0500
Committer: Robert (Bobby) Evans <bo...@apache.org>
Committed: Thu Jun 26 16:08:59 2014 -0500

----------------------------------------------------------------------
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/b659979a/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bdc6af0..2506a97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
  * STORM-355: excluding outdated netty transitively included via curator
  * STORM-183: Replacing RunTime.halt() with RunTime.exit()
  * STORM-213: Decouple In-Process ZooKeeper from LocalCluster.
+ * STORM-365: Add support for Python 3 to storm command.
 
 ## 0.9.2-incubating
  * STORM-66: send taskid on initial handshake