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 2015/07/21 11:52:35 UTC

[2/4] storm git commit: 1. Moved arg check within the method call 2. Made use of exiting print_usage function 3. System exit code 2 to be returned for incomplete command

1. Moved arg check within the method call
2. Made use of exiting print_usage function
3. System exit code 2 to be returned for incomplete command


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

Branch: refs/heads/master
Commit: 02ca2e96c97212b860c49b634c93e0c12dcf3e9f
Parents: 78bd1f4
Author: Shyam Rajendran <rs...@gmail.com>
Authored: Fri Jul 17 23:26:40 2015 -0500
Committer: Shyam Rajendran <rs...@gmail.com>
Committed: Fri Jul 17 23:59:06 2015 -0500

----------------------------------------------------------------------
 bin/storm.py | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/02ca2e96/bin/storm.py
----------------------------------------------------------------------
diff --git a/bin/storm.py b/bin/storm.py
index ea52a8f..a6d08db 100755
--- a/bin/storm.py
+++ b/bin/storm.py
@@ -22,7 +22,6 @@ import random
 import subprocess as sub
 import re
 import shlex
-import inspect
 try:
     # python 3
     from urllib.parse import quote_plus
@@ -162,9 +161,6 @@ def print_remoteconfvalue(name):
     """
     print(name + ": " + confvalue(name, [CLUSTER_CONF_DIR]))
 
-def print_help(func):
-    print(func.__doc__)
-    sys.exit(0)
 def parse_args(string):
     r"""Takes a string of whitespace-separated tokens and parses it into a list.
     Whitespace inside tokens may be quoted with single quotes, double quotes or
@@ -186,11 +182,6 @@ def parse_args(string):
 
 def exec_storm_class(klass, jvmtype="-server", jvmopts=[], extrajars=[], args=[], fork=False, daemon=True, daemonName=""):
     global CONFFILE
-    arg_check = ['kill', 'upload_credentials', 'activate', 'deactivate', 'rebalance', 'get_errors']
-    func = inspect.stack()[1][3]
-    if not args and func in arg_check:
-        print(eval(func).__doc__)
-        sys.exit(0)
     storm_log_dir = confvalue("storm.log.dir",[CLUSTER_CONF_DIR])
     if(storm_log_dir == None or storm_log_dir == "nil"):
         storm_log_dir = os.path.join(STORM_DIR, "logs")
@@ -241,7 +232,8 @@ def kill(*args):
     of time Storm waits between deactivation and shutdown with the -w flag.
     """
     if not args:
-        print_help(kill)
+        print_usage(command="kill")
+        sys.exit(2)
     exec_storm_class(
         "backtype.storm.command.kill_topology",
         args=args,
@@ -255,7 +247,8 @@ def upload_credentials(*args):
     Uploads a new set of credentials to a running topology
     """
     if not args:
-        print_help(upload_credentials)
+        print_usage(command="upload_credentials")
+        sys.exit(2)
     exec_storm_class(
         "backtype.storm.command.upload_credentials",
         args=args,
@@ -268,7 +261,8 @@ def activate(*args):
     Activates the specified topology's spouts.
     """
     if not args:
-        print_help(activate)
+        print_usage(command="activate")
+        sys.exit(2)
     exec_storm_class(
         "backtype.storm.command.activate",
         args=args,
@@ -292,7 +286,8 @@ def deactivate(*args):
     Deactivates the specified topology's spouts.
     """
     if not args:
-        print_help(deactivate)
+        print_usage(command="deactivate")
+        sys.exit(2)
     exec_storm_class(
         "backtype.storm.command.deactivate",
         args=args,
@@ -321,7 +316,8 @@ def rebalance(*args):
     respectively.
     """
     if not args:
-        print_help(rebalance)
+        print_usage(command="rebalance")
+        sys.exit(2)
     exec_storm_class(
         "backtype.storm.command.rebalance",
         args=args,
@@ -336,7 +332,8 @@ def get_errors(*args):
     The result is returned in json format.
     """
     if not args:
-        print_help(get_errors)
+        print_usage(command="get_errors")
+        sys.exit(2)
     exec_storm_class(
         "backtype.storm.command.get_errors",
         args=args,