[Zope-Checkins] CVS: Zope/inst/skel/inst/in - zctl.in:1.1.2.1

Chris McDonough chrism@zope.com
Sun, 29 Sep 2002 17:46:25 -0400


Update of /cvs-repository/Zope/inst/skel/inst/in
In directory cvs.zope.org:/tmp/cvs-serv12114/inst/skel/inst/in

Added Files:
      Tag: chrism-install-branch
	zctl.in 
Log Message:
Updates to the chrism-install-branch:

  - Uses distutils (setup.py) to install all software kept in the
    'lib/python' directory.  This means that the setup.py file
    (which has moved into the inst directory) will need to be maintained
    as new packages, files, and directories are added.  This is
    painful, but it's "the right thing".  It is a departure from the
    past inasmuch as (if this branch is merged into the head at some
    point) when people add stuff to the Zope tree, they will need to
    be careful to update the setup.py file as well.  I know this will become
    incredibly problematic.  To make things easier, it might be
    a reasonable thing to autogenerate a setup.py file based on the
    current state of the Zope tree.  But this is not done yet.
    BTW, many thanks to Matt Hamilton for making the incredible setup.py file
    for all Zope packages.

  - No longer copies the build directory wholesale to create a
    ZOPE_HOME.  Instead 'make install' copies a 'skeleton' directory to the 
    target dir using a custom Python installer and writes out
    files that need post-processing (.in files) to places in the
    hierarchy as needed via the Makefile.  This prevents a lot of
    cruft from reaching the target directory (build directories,
    emacs backup files, etc.)

  - Has an improved 'make instance' implementation which also uses
    a skeleton directory and a similar install.

  - Does away with much cruft in the 'inst' directory lefover from
    band-aids that were produced in the past.

Concessions were made to the realities of moving directories in CVS
for this go-around.  It is desirable to move lots of the current
"top-level" directories (import, var, utilities, Extensions, pcgi, etc.)
into the "skeleton" directory for the kind of install strategy implemented
by this branch, but this is not reasonable as we would divorce these 
packages from updates received on the head if were were to do so now.
If we merge this branch into the head, we will do away with the workarounds
and move the directories.
  


=== Added File Zope/inst/skel/inst/in/zctl.in === (712/812 lines abridged)
#!<<PYTHON>>
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
    Zope appserver controller.  This is akin to apache's apachectl,
    except with an interactive interpreter if no commands are specified
    on the command-line.
"""

__version__ = '$Revision: 1.1.2.1 $'[11:-2]

import getopt, os, sys, re, signal, cmd, time
try:
    import readline
except:
    readline = None

_marker = []

CONFIG_LOCATION ='<<CONFIG_LOCATION>>'
ZOPE_HOME     = '<<BASE_DIR>>'
ZOPE_PY_LOCATION = os.path.join(ZOPE_HOME, 'bin', 'zope.py')
SOFTWARE_HOME = os.path.join(ZOPE_HOME, 'lib', 'python')

sys.path.insert(0, SOFTWARE_HOME)
sys.path = filter(None, sys.path)

from Controller.Directives import DirectiveRegistry
from Controller import TextBlockFormatter

USAGE = """\

zctl:  Zope appserver controller

Usage:
    zctl [-h | --help] [--config-location=filepath or url]

Options:
    -h or --help       Print this message.  Not compatible with the 'start'
                       or 'restart' command.

[-=- -=- -=- 712 lines omitted -=- -=- -=-]

        except getopt.GetoptError, v:
            print v
            self.usage()
            sys.exit(127)
        
        for k, v in o:
            if k in ('-h', '--help'):
                self.usage()
                sys.exit(0)
            elif k == '--config-location':
                config_location = v
        reg = DirectiveRegistry
        reg.reconfigure(config_location)
        self._engine._setConfig(reg)
        self._engine._setCommandLineOpts(o)
        if a:
            self.cmdqueue.append( ' '.join( a ) )
            self.cmdqueue.append( 'EOF' )

        self.cmdloop()

def get_pids(filename):
    for line in open(filename).readlines():
        pids = line.split()
        if pids:
            return [ int(x.strip()) for x in pids ]

def kill(pid, sig):
    if sys.platform == 'win32':
        # we ignore the signal on win32
        import win32api
        handle = win32api.OpenProcess(1, 0, pid)
        try:
            return (0 != win32api.TerminateProcess(handle, 0))
        except:
            return 1
    else:
        try:
            os.kill(pid, sig)
        except OSError, why:
            return 1
        else:
            return 0

    
if __name__ == '__main__':

    cmd = _ZopeCtlCmd()
    cmd.main()