Author: remi
Date: 2009-03-13 16:01:15 +0100 (Fri, 13 Mar 2009)
New Revision: 4057

Modified:
   software_suite_v2/tuxware/tuxdroidserver/trunk/tuxhttpserver.py
Log:
* applied Paul's patch to uses getopt instead of basic argument parsing

Modified: software_suite_v2/tuxware/tuxdroidserver/trunk/tuxhttpserver.py
===================================================================
--- software_suite_v2/tuxware/tuxdroidserver/trunk/tuxhttpserver.py     
2009-03-13 14:29:08 UTC (rev 4056)
+++ software_suite_v2/tuxware/tuxdroidserver/trunk/tuxhttpserver.py     
2009-03-13 15:01:15 UTC (rev 4057)
@@ -14,6 +14,7 @@
 
 import sys
 import os
+import getopt
 
 from TDSConfiguration import *
 
@@ -62,6 +63,23 @@
     httpServer.start()
     finalizeServer()
 
+def usage():
+    print '-'*80
+    print 'Tux HTTP Server v. : %s'%__version__
+    print 'Release date : %s'%__date__
+    print 'Author       : %s'%__author__
+    print 'Released under %s license'%__licence__
+    print ''
+    print '  Usage :'
+    print '  python tuxhttpserver.py [slrh]'
+    print '  -s , --stop    : Stop the server'
+    print '  -l , --start   : Start the server'
+    print '  -r , --restart : Restart the server'
+    print '  -h , --help    : Display this help'
+    print ''
+    print '-'*80
+    print ''
+
 # 
------------------------------------------------------------------------------
 # Main
 # 
------------------------------------------------------------------------------
@@ -74,17 +92,25 @@
             tuxDroidDaemon = Daemonizer('tuxhttpserver', '/var/log',
                 runServer, True)
             tuxDroidDaemon.start()
-    # Server called with an argument
-    if len(sys.argv) > 1:
-        if sys.argv[1] == "--start":
+
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], "slrh", \
+                ["stop", "start", "restart", "help"])
+    except getopt.error, msg:
+        print msg
+        usage()
+        sys.exit(2)
+
+    for o,a in opts:
+        if o in ("-h", "--help"):
+            usage()
+            sys.exit(0)
+        if o in ("-s", "--stop"):
+            killServer()
+        elif o in ("-l", "--start"):
             start()
-        elif sys.argv[1] == "--restart":
+        elif o in ("-r", "--restart"):
             killServerAndWait()
             start()
-        elif sys.argv[1] == "--stop":
-            killServer()
         else:
             start()
-    # Without argument : Server start
-    else:
-        start()


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to