[Zope-Checkins] CVS: Zope/ZopeControl - __init__.py:1.1.2.1 zope.in:1.1.2.1

Matt Behrens matt@zigg.com
Sun, 19 May 2002 21:37:34 -0400


Update of /cvs-repository/Zope/ZopeControl
In directory cvs.zope.org:/tmp/cvs-serv14149/ZopeControl

Added Files:
      Tag: zigg_unix-install-control-config-branch
	__init__.py zope.in 
Log Message:
Kick off the Grand Unified Installer/Controller/Configurator branch.

This is only half done right now, and doesn't deliver everything I
have promised just yet, so don't expect magic.  However,

- setup.py will install ALL of Zope for you, i.e.

	python2.1 setup.py --home=/where/ever/you/want

- configure is mostly done,

- 'make build' and 'make install' work largely as expected.

The controller in particular probably doesn't work yet, but it's a
short leap from here to there.

(Note: I see fdrake committed setup.py-age on HEAD for ZCTextIndex,
but that module is not actually on the HEAD for Zope?  Am I missing
something?)



=== Added File Zope/ZopeControl/__init__.py ===
#
# Copyright (c) 2002 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
# 
##############################################################################

"""
Functions that implement commands that can be given to the zope
system control utility.
"""

def help(instance, args):
    print "If we were providing help, you'd see it here."



=== Added File Zope/ZopeControl/zope.in ===
#!@PYTHON@
#
# Copyright (c) 2002 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
# 
##############################################################################

# Bump this number if you want the Zope installer to replace a lower-numbered
# version of this script with this script.
version = 0

# Configuration information, written by the source distribution's configure
# script.
configured = {
    # GNU-style configured paths
    'PREFIX':		'@PREFIX@',
    'BINDIR':		'@BINDIR@',
    'ETCDIR':		'@ETCDIR@',
    'LIBDIR':		'@LIBDIR@',
    'VARDIR':		'@VARDIR@',
    # Additional Zope configured paths
    'CONFIG_DIR':	'@CONFIG_DIR@',
    'SOFTWARE_DIR':	'@SOFTWARE_DIR@',
    'INSTANCE_DIR':     '@INSTANCE_DIR@',
}

import ConfigParser, os, string, sys

def do(command, instance, args):
    if command == 'config':
    	# Output configured variables and exit.
    	for key in configured.keys():
	    print '%s=%s' % (key, configured[key])
	sys.exit(0)

    # Determine software and instance homes for the given instance.
    instance_conf = getInstanceConf(instance)
    instance_home = instance_conf.get('Paths', 'InstanceHome')
    software_name = instance_conf.get('Software', 'SoftwareName')
    software_home = getSoftwareConf().get('SoftwareHomes', software_name)

    # Import Control from the instance home or fallback to software home.
    sys.path.insert(0, software_home)
    sys.path.insert(0, instance_home)
    import Control

    # Run the given command.
    Control[command](instance, args)

def getDefaultInstance():
    return getSystemConf().get('Defaults', 'Instance')

def getInstanceConf(instance):
    instance_conf = ConfigParser.ConfigParser()
    instance_conf.read(os.path.join(configured['CONFIG_DIR'],
				    instance,
				    'instance.conf'))
    return instance_conf

def getSystemConf():
    system_conf = ConfigParser.ConfigParser()
    system_conf.read(os.path.join(configured['CONFIG_DIR'], 'system.conf'))
    return system_conf

def printUsage():
    print "Usage: %s <command> [<instance>] [<arg> [<arg> ...]]"

if __name__ == '__main__':
    argc = len(sys.argv)
    if argc > 1:
    	command = string.lower(sys.argv[1])
	if argc > 2:
	    if sys.argv[2][0] == '-':
		instance = getDefaultInstance()
		args = sys.argv[2:]
	    else:
		instance = sys.argv[2]
		args = sys.argv[3:]
	else:
	    instance = getDefaultInstance()
	    args = []
	do(command, instance, args)
	sys.exit(0)
    else:
	printUsage()
	sys.exit(1)