[Opensrf-commits] r1340 - trunk/src/python

svn at svn.open-ils.org svn at svn.open-ils.org
Fri May 23 10:59:54 EDT 2008


Author: erickson
Date: 2008-05-23 10:59:52 -0400 (Fri, 23 May 2008)
New Revision: 1340

Modified:
   trunk/src/python/opensrf.py
Log:
default to help when invalid option is provided

Modified: trunk/src/python/opensrf.py
===================================================================
--- trunk/src/python/opensrf.py	2008-05-23 14:49:25 UTC (rev 1339)
+++ trunk/src/python/opensrf.py	2008-05-23 14:59:52 UTC (rev 1340)
@@ -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 @@
             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 @@
 
 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 == 'restart':
     do_stop()
     do_start()
+
+elif action == 'help':
+    do_help()



More information about the opensrf-commits mailing list