From 2c3637ad757b199a3087f2d232a795efb50e7728 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Mon, 21 Dec 2009 00:22:22 -0500 Subject: [PATCH] invirt.fcgi: fix usage message, simplify option-parsing logic svn path=/trunk/packages/invirt-web/; revision=2741 --- code/invirt.fcgi | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/code/invirt.fcgi b/code/invirt.fcgi index 0bce132..607a4ea 100755 --- a/code/invirt.fcgi +++ b/code/invirt.fcgi @@ -13,28 +13,29 @@ base_dir = os.path.dirname(__file__) def usage(): argv0_dir = os.path.dirname(sys.argv[0]) print >>sys.stderr, """%s [config] -%s/auth.fcgi [config] -%s/unauth.fcgi [config] Run server as FastCGI, with CherryPy config from "main.conf". - With `config`, run standalone with CherryPy config from `config`. -Run this script as either 'auth.fcgi' or 'unauth.fcgi', to get -the authenticated or unauthenticated site respectively, or pass -'auth' or 'unauth' as the first parameter. +Serve the authenticated or unauthenticated site according to +the first argument. + +Helper scripts "auth.fcgi" and "unauth.fcgi" are provided to +facilitate running the server with no arguments. """ % (sys.argv[0], argv0_dir, argv0_dir) sys.exit(2) if __name__ == "__main__": - if len(sys.argv) > 3 or len(sys.argv) == 1 or '-h' in sys.argv or '--help' in sys.argv: + if '-h' in sys.argv or '--help' in sys.argv: usage() + if not (2 <= len(sys.argv) <= 3): + usage() + + mode = sys.argv[1] if len(sys.argv) == 3: - mode = sys.argv[1] conf_file = sys.argv[2] dev = True else: - mode = sys.argv[1] conf_file = os.path.join(base_dir, 'main.conf') app_config = { -- 1.7.9.5