You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2014/04/02 17:51:13 UTC

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

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 <ao...@hortonworks.com>
Authored: Wed Apr 2 08:50:11 2014 -0700
Committer: Andrew Onischuk <ao...@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]