[Zope-Checkins] CVS: Zope/inst - zctl.in:1.1.2.1 make_instance.py:1.3.4.3 zopectl.in:NONE

Chris McDonough chrism@zope.com
Thu, 29 Aug 2002 01:22:10 -0400


Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv27577/inst

Modified Files:
      Tag: chrism-install-branch
	make_instance.py 
Added Files:
      Tag: chrism-install-branch
	zctl.in 
Removed Files:
      Tag: chrism-install-branch
	zopectl.in 
Log Message:
- Renamed zopectl to zctl ('zope<tab> always finds zope.conf too!)

- Created a new 'make instance' target in Makefile for running from
  a "build" directory directly.

- Updated some directives and refactored directive code.

- zctl show now shows directives instead of command-line switches
  and envvars in output.


=== Added File Zope/inst/zctl.in ===
#!%(python)s
"""
    Zope appserver controller.
"""
import os, sys
SOFTWARE_HOME = '%(software_home)s/lib/python'

USAGE = """\

zopectl:  Zope appserver controller

Usage:
    zopectl [--config=filepath] [commands*]

Options:
    --config    Use an alternate configuration file.  Default: 'zope.conf'

Commands:
    help [<command>]
    start
    stop
    restart
    logrotate
    status
    show [<info>*]
    run <script_filename>
    debug

    If no commands supplied, runs as an interactive read-eval-print
    interpreter.
"""
sys.path.insert(0, SOFTWARE_HOME)
from Controller.ZopeCtl import ZopeCtl, normalizeDocstring

#
#   Read-eval-print interpreter
#
def _MAKEDO( command ):
    """
        Work around insistence of 'Cmd.help' on printing docstrings with
        full indentation;  we fabricate a function which has the docstring
        it expects, using the one from ZopeCtl as a starting point;
        the generated function is suitable for use as 'do_command' within
        the Cmd-derived class.
    """

    def xdo( self, args=None, command=command ):
        getattr( self._engine, command )( args )

    xdo.func_doc = normalizeDocstring( getattr( ZopeCtl, command ) )
        
    return xdo

import cmd

class _ZopeCtlCmd( cmd.Cmd ):
    """
        Interactive command processor.
    """
    def __init__( self, prompt='zopectl> ', verbosity=1 ):

        self._engine    = ZopeCtl( self._report )
        self.prompt     = prompt
        self._verbosity = verbosity

    def _report( self, msg='', level=1 ):

        if self._verbosity >= level:
            print msg

    def default( self, line ):

        if line == 'EOF':
            self._report()
            return 1

        try:
            tokens = line.split()
            method, args = tokens[0], ' '.join( tokens[1:] )
            method = getattr( self._engine, method, None )
            if method is not None:
                method( args )
                return None
        except:
            pass

        return cmd.Cmd.default( self, line )

    do_start         = _MAKEDO( 'start' )
    do_start         = _MAKEDO( 'start' )
    do_restart       = _MAKEDO( 'restart' )
    do_logopenclose  = _MAKEDO( 'logopenclose' )
    do_logtail       = _MAKEDO( 'logtail' )
    do_stop          = _MAKEDO( 'stop' )
    do_status        = _MAKEDO( 'status' )
    do_show          = _MAKEDO( 'show' )
    do_run           = _MAKEDO( 'run' )
    do_debug         = _MAKEDO( 'debug' )
    do_quit          = _MAKEDO( 'quit' )
    do_set           = _MAKEDO( 'set'  )

    #
    #   Command-line processing
    #
    def usage( self ):

        import sys

        self._report( USAGE )

        sys.exit( 2 )

    def main( self ):

        import sys
        import os
        import getopt

        try:
            options, args = getopt.getopt( sys.argv[1:], '', [ 'config=' ] )
        except getopt.GetoptError:
            self.usage()
        
        for k, v in options:

            if k == '--config':
                self._engine._setConfigFile( os.path.normpath( v ) )
            else:
                usage()

        if args:
            self.cmdqueue.append( ' '.join( args ) )
            self.cmdqueue.append( 'EOF' )

        self.cmdloop()

if __name__ == '__main__':

    _ZopeCtlCmd().main()


=== Zope/inst/make_instance.py 1.3.4.2 => 1.3.4.3 ===
--- Zope/inst/make_instance.py:1.3.4.2	Mon Aug 26 02:22:36 2002
+++ Zope/inst/make_instance.py	Thu Aug 29 01:22:08 2002
@@ -89,7 +89,7 @@
     print
     sys.path.insert(0, home)
     choose_inituser(ih)
-    print 'Done!  Use "%s/zopectl start" to start Zope.' % ih
+    print 'Done!  Use "%s/zctl start" to start Zope.' % ih
 
 def choose_inituser(home):
     ac_path=os.path.join(home, 'inituser')

=== Removed File Zope/inst/zopectl.in ===