From fb441b2b1054de1ba0a99d01b9e1ea9700024aeb Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 22 Oct 2008 23:00:45 -0600 Subject: make-doc now includes the lite-* scripts, both with now check in __name__ == '__main__' before starting --- ipa | 9 ++++--- lite-webui.py | 5 ++-- lite-xmlrpc.py | 82 +++++++++++++++++++++++++++++++++++++--------------------- make-doc | 2 +- 4 files changed, 61 insertions(+), 37 deletions(-) diff --git a/ipa b/ipa index 5122af0a..b202a5d0 100755 --- a/ipa +++ b/ipa @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Authors: # Jason Gerard DeRose @@ -20,7 +20,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -Command Line Interface for IPA Administration. +Command Line Interface for IPA administration. The CLI functionality is implemented in ipalib/cli.py """ @@ -30,5 +30,6 @@ from ipalib import api from ipalib.cli import CLI import ipalib.load_plugins -cli = CLI(api) -sys.exit(cli.run()) +if __name__ == '__main__': + cli = CLI(api) + sys.exit(cli.run()) diff --git a/lite-webui.py b/lite-webui.py index c910f83d..ccef77ed 100755 --- a/lite-webui.py +++ b/lite-webui.py @@ -1,6 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python -# Authors: Jason Gerard DeRose +# Authors: +# Jason Gerard DeRose # # Copyright (C) 2008 Red Hat # see file 'COPYING' for use and warranty information diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 49f3a2ae..88ef1512 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -1,5 +1,28 @@ #!/usr/bin/env python +# Authors: +# Rob Crittenden +# +# Copyright (C) 2008 Red Hat +# see file 'COPYING' for use and warranty information +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2 only +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +""" +In-tree XML-RPC server using SimpleXMLRPCServer. +""" + import sys import SimpleXMLRPCServer import logging @@ -15,9 +38,6 @@ import ipalib.load_plugins from ipalib.util import xmlrpc_unmarshal import traceback -""" -In-tree XML-RPC server using SimpleXMLRPCServer. -""" PORT=8888 @@ -134,37 +154,39 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa self.wfile.flush() self.connection.shutdown(1) -# Set up our logger -logger = logging.getLogger('xmlrpcserver') -hdlr = logging.FileHandler('xmlrpcserver.log') -formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s") -hdlr.setFormatter(formatter) -logger.addHandler(hdlr) -logger.setLevel(logging.INFO) -# Set up the server -XMLRPCServer = StoppableXMLRPCServer(("",PORT), LoggingSimpleXMLRPCRequestHandler) +if __name__ == '__main__': + # Set up our logger + logger = logging.getLogger('xmlrpcserver') + hdlr = logging.FileHandler('xmlrpcserver.log') + formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s") + hdlr.setFormatter(formatter) + logger.addHandler(hdlr) + logger.setLevel(logging.INFO) + + # Set up the server + XMLRPCServer = StoppableXMLRPCServer(("",PORT), LoggingSimpleXMLRPCRequestHandler) -XMLRPCServer.register_introspection_functions() + XMLRPCServer.register_introspection_functions() -api.finalize() + api.finalize() -# Initialize our environment -config.set_default_env(api.env) -env_dict = config.read_config() -env_dict['server_context'] = True -api.env.update(env_dict) + # Initialize our environment + config.set_default_env(api.env) + env_dict = config.read_config() + env_dict['server_context'] = True + api.env.update(env_dict) -# Get and register all the methods -for cmd in api.Command: - logger.info("registering %s" % cmd) - XMLRPCServer.register_function(api.Command[cmd], cmd) + # Get and register all the methods + for cmd in api.Command: + logger.info("registering %s" % cmd) + XMLRPCServer.register_function(api.Command[cmd], cmd) -funcs = XMLRPCServer.funcs + funcs = XMLRPCServer.funcs -print "Listening on port %d" % PORT -try: - XMLRPCServer.serve_forever() -except KeyboardInterrupt: - XMLRPCServer.server_close() - print "Server shutdown." + print "Listening on port %d" % PORT + try: + XMLRPCServer.serve_forever() + except KeyboardInterrupt: + XMLRPCServer.server_close() + print "Server shutdown." diff --git a/make-doc b/make-doc index a4ee095b..1c50d2c8 100755 --- a/make-doc +++ b/make-doc @@ -2,7 +2,7 @@ # Hackish script to generate documentation using epydoc -sources="ipalib ipa_server ipa_webui tests" +sources="ipalib ipa_server ipa_webui tests lite-xmlrpc.py lite-webui.py" out="./freeipa2-dev-doc" init="./ipalib/__init__.py" -- cgit