From e69a4ca86be5744f78335f57289f83842cbab3e3 Mon Sep 17 00:00:00 2001 From: bdauvergne Date: Mon, 27 Apr 2009 13:02:37 +0000 Subject: [PATCH] Add stdandard command line options * larpe/ctl/start.py: add standard options --http, --data-dir, --app-dir. --script-name cannot be used with http. git-svn-id: svn+ssh://labs.libre-entreprise.org/svnroot/larpe@471 3ed937ae-f919-0410-9a43-8e6f19e4ba6e --- larpe/trunk/larpe/ctl/start.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/larpe/trunk/larpe/ctl/start.py b/larpe/trunk/larpe/ctl/start.py index de41324..c404202 100644 --- a/larpe/trunk/larpe/ctl/start.py +++ b/larpe/trunk/larpe/ctl/start.py @@ -1,29 +1,47 @@ import socket import sys +import quixote.server.simple_server from qommon.scgi_server import run import publisher def start(args): - port = 3007 - script_name = '' + run_function = run + run_kwargs = { + 'port': 3007, + 'script_name': '' + } + http = 0 i = 0 while i < len(args): if args[i] == '--port': - port = int(args[i+1]) + run_kwargs['port'] = int(args[i+1]) i += 1 elif args[i] == '--silent': sys.stdout = open('/dev/null', 'w') sys.stderr = open('/dev/null', 'w') elif args[i] == '--script-name': - script_name = args[i+1] + run_kwargs['script_name'] = args[i+1] i += 1 + elif args[i] == '--app-dir': + publisher.LarpePublisher.APP_DIR = args[i+1] + i += 1 + elif args[i] == '--data-dir': + publisher.LarpePublisher.DATA_DIR = args[i+1] + i += 1 + elif args[i] == '--http': + http = 1 i += 1 + if http == 1: + run_function = quixote.server.simple_server.run + if run_kwargs['script_name']: + print "--http option is incompatible with --script-name" + del run_kwargs['script_name'] try: - run(publisher.LarpePublisher.create_publisher, port=port, script_name=script_name) + run_function(publisher.LarpePublisher.create_publisher, **run_kwargs) except socket.error, err: if err[0] == 98: print >> sys.stderr, 'address already in use'