ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject git commit: AMBARI-5317. Create test script for running python component scripts from IDE (aonishuk)
Date Wed, 02 Apr 2014 15:51:13 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f4f30dd69 -> f9db0c636


AMBARI-5317. Create test script for running python component scripts from IDE (aonishuk)


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

Branch: refs/heads/trunk
Commit: f9db0c6363a0c415df6e62224af58542d4eeb2a1
Parents: f4f30dd
Author: Andrew Onischuk <aonishuk@hortonworks.com>
Authored: Wed Apr 2 08:50:11 2014 -0700
Committer: Andrew Onischuk <aonishuk@hortonworks.com>
Committed: Wed Apr 2 08:50:47 2014 -0700

----------------------------------------------------------------------
 .../resource_management/libraries/script/script.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f9db0c63/ambari-agent/src/main/python/resource_management/libraries/script/script.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/script/script.py b/ambari-agent/src/main/python/resource_management/libraries/script/script.py
index 005d915..d62bcd1 100644
--- a/ambari-agent/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-agent/src/main/python/resource_management/libraries/script/script.py
@@ -20,6 +20,7 @@ limitations under the License.
 
 __all__ = ["Script"]
 
+import os
 import sys
 import json
 import logging
@@ -30,6 +31,14 @@ from resource_management.core.resources.packaging import Package
 from resource_management.libraries.script.config_dictionary import ConfigDictionary
 from resource_management.libraries.script.repo_installer import RepoInstaller
 
+USAGE = """Usage: {0} <COMMAND> <JSON_CONFIG> <BASEDIR> <STROUTPUT>
+
+<COMMAND> command type (INSTALL/CONFIGURE/START/STOP/SERVICE_CHECK...)
+<JSON_CONFIG> path to command json file. Ex: /var/lib/ambari-agent/data/command-2.json
+<BASEDIR> path to service metadata dir. Ex: /var/lib/ambari-agent/cache/stacks/HDP/2.0.6/services/HDFS
+<STROUTPUT> path to file with structured command output (file will be created). Ex:/tmp/my.txt
+"""
+
 class Script(object):
   """
   Executes a command for custom service. stdout and stderr are written to
@@ -73,9 +82,11 @@ class Script(object):
     logger.addHandler(cherr)
     logger.addHandler(chout)
     # parse arguments
-    if len(sys.argv) < 5:
-      logger.error("Script expects at least 4 arguments")
-      sys.exit(1)
+    if len(sys.argv) < 5: 
+     logger.error("Script expects at least 4 arguments")
+     print USAGE.format(os.path.basename(sys.argv[0])) # print to stdout
+     sys.exit(1)
+      
     command_name = str.lower(sys.argv[1])
     # parse command parameters
     command_data_file = sys.argv[2]


Mime
View raw message