From f8c8fdf19d6a81cacf35e90d09563ebd90948d20 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 23 May 2008 14:59:52 +0000 Subject: [PATCH] default to help when invalid option is provided git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1340 9efc2488-bf62-4759-914b-345cdb29e865 --- src/python/opensrf.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/python/opensrf.py b/src/python/opensrf.py index 2be6da3..2c3aad8 100755 --- a/src/python/opensrf.py +++ b/src/python/opensrf.py @@ -22,7 +22,7 @@ import sys, getopt, os, signal import osrf.system, osrf.server, osrf.app -def help(): +def do_help(): print ''' Manage OpenSRF application processes @@ -45,17 +45,27 @@ def help(): The location of application PID files. Default is /tmp -d - If set, run in daemon (background) mode + If set, run in daemon (background) mode. This creates a PID + file for managing the process. + + -h + Prints help message ''' sys.exit(0) # Parse the command line options -ops, args = getopt.getopt(sys.argv[1:], 'a:s:f:c:p:d') +ops, args = None, None +try: + ops, args = getopt.getopt(sys.argv[1:], 'a:s:f:c:p:dh') +except getopt.GetoptError, e: + print '* %s' % str(e) + do_help() + options = dict(ops) if '-a' not in options or '-s' not in options or '-f' not in options: - help() + do_help() action = options['-a'] service = options['-s'] @@ -68,7 +78,6 @@ pidfile = "%s/osrf_py_%s.pid" % (pid_dir, service) def do_start(): - # connect to the OpenSRF network osrf.system.System.net_connect( config_file = config_file, config_context = config_ctx) @@ -108,3 +117,6 @@ elif action == 'stop': elif action == 'restart': do_stop() do_start() + +elif action == 'help': + do_help() -- 2.43.2