[Checkins] SVN: zope.mkzeoinst/trunk/ Fork the mkzeoinst script from ZODB 3.9.4.
Tres Seaver
tseaver at palladion.com
Thu Apr 22 14:18:04 EDT 2010
Log message for revision 111274:
Fork the mkzeoinst script from ZODB 3.9.4.
Changed:
A zope.mkzeoinst/trunk/.bzrignore
A zope.mkzeoinst/trunk/CHANGES.txt
A zope.mkzeoinst/trunk/COPYRIGHT.txt
A zope.mkzeoinst/trunk/LICENSE.txt
A zope.mkzeoinst/trunk/README.txt
A zope.mkzeoinst/trunk/setup.py
A zope.mkzeoinst/trunk/src/
A zope.mkzeoinst/trunk/src/zope/
A zope.mkzeoinst/trunk/src/zope/__init__.py
A zope.mkzeoinst/trunk/src/zope/mkzeoinst/
A zope.mkzeoinst/trunk/src/zope/mkzeoinst/__init__.py
-=-
Added: zope.mkzeoinst/trunk/.bzrignore
===================================================================
--- zope.mkzeoinst/trunk/.bzrignore (rev 0)
+++ zope.mkzeoinst/trunk/.bzrignore 2010-04-22 18:18:04 UTC (rev 111274)
@@ -0,0 +1 @@
+*.egg-info
Added: zope.mkzeoinst/trunk/CHANGES.txt
===================================================================
--- zope.mkzeoinst/trunk/CHANGES.txt (rev 0)
+++ zope.mkzeoinst/trunk/CHANGES.txt 2010-04-22 18:18:04 UTC (rev 111274)
@@ -0,0 +1,9 @@
+``zope.mkzeoinst`` Changelog
+============================
+
+
+3.9.4 (unreleased)
+------------------
+
+- Forked from the version of the ``mkzeoinst`` script contained in
+ ZODB 3.9.4.
Added: zope.mkzeoinst/trunk/COPYRIGHT.txt
===================================================================
--- zope.mkzeoinst/trunk/COPYRIGHT.txt (rev 0)
+++ zope.mkzeoinst/trunk/COPYRIGHT.txt 2010-04-22 18:18:04 UTC (rev 111274)
@@ -0,0 +1 @@
+Zope Foundation and Contributors
\ No newline at end of file
Added: zope.mkzeoinst/trunk/LICENSE.txt
===================================================================
--- zope.mkzeoinst/trunk/LICENSE.txt (rev 0)
+++ zope.mkzeoinst/trunk/LICENSE.txt 2010-04-22 18:18:04 UTC (rev 111274)
@@ -0,0 +1,44 @@
+Zope Public License (ZPL) Version 2.1
+
+A copyright notice accompanies this license document that identifies the
+copyright holders.
+
+This license has been certified as open source. It has also been designated as
+GPL compatible by the Free Software Foundation (FSF).
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions in source code must retain the accompanying copyright
+notice, this list of conditions, and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the accompanying copyright
+notice, this list of conditions, and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+3. Names of the copyright holders must not be used to endorse or promote
+products derived from this software without prior written permission from the
+copyright holders.
+
+4. The right to distribute this software or to use it for any purpose does not
+give you the right to use Servicemarks (sm) or Trademarks (tm) of the
+copyright
+holders. Use of them is covered by separate agreement with the copyright
+holders.
+
+5. If any files are modified, you must cause the modified files to carry
+prominent notices stating that you changed the files and the date of any
+change.
+
+Disclaimer
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
+OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Added: zope.mkzeoinst/trunk/README.txt
===================================================================
--- zope.mkzeoinst/trunk/README.txt (rev 0)
+++ zope.mkzeoinst/trunk/README.txt 2010-04-22 18:18:04 UTC (rev 111274)
@@ -0,0 +1,5 @@
+``zope.mkzeoinst`` README
+=========================
+
+This package provides a single script, ``mkzeoinst``, which creates
+a standalone ZEO server instance.
Added: zope.mkzeoinst/trunk/setup.py
===================================================================
--- zope.mkzeoinst/trunk/setup.py (rev 0)
+++ zope.mkzeoinst/trunk/setup.py 2010-04-22 18:18:04 UTC (rev 111274)
@@ -0,0 +1,63 @@
+##############################################################################
+#
+# Copyright (c) 2003, 2010 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+""" Setup for zope.mkzeoinst package
+"""
+
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+ name='zope.mkzeoinst',
+ version='3.9.4',
+ url='http://pypi.python.org/pypi/zope.mkzeoinst',
+ license='ZPL 2.1',
+ description='Make standalone ZEO database server instances',
+ author='Zope Foundation and Contributors',
+ author_email='zope-dev at zope.org',
+ long_description=(
+ read('README.txt')
+ + '\n' +
+ read('CHANGES.txt')
+ ),
+ classifiers=[
+ "Development Status :: 5 - Production/Stable",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: Zope Public License",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python :: 2.4",
+ "Programming Language :: Python :: 2.5",
+ "Programming Language :: Python :: 2.6",
+ "Programming Language :: Python :: 3.1",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+ ],
+
+ packages=find_packages('src'),
+ package_dir={'': 'src'},
+ namespace_packages=['zope',],
+ include_package_data=True,
+ install_requires=[
+ 'setuptools',
+ 'ZODB3 >= 3.9.4',
+ ],
+ zip_safe=False,
+ test_suite='zope.mkzeoinst.tests.test_suite',
+ entry_points = {
+ 'console_scripts': [
+ 'mkzeoinst = zope.mkzeoinst:main',
+ ],
+ },
+)
Added: zope.mkzeoinst/trunk/src/zope/__init__.py
===================================================================
--- zope.mkzeoinst/trunk/src/zope/__init__.py (rev 0)
+++ zope.mkzeoinst/trunk/src/zope/__init__.py 2010-04-22 18:18:04 UTC (rev 111274)
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__)
Added: zope.mkzeoinst/trunk/src/zope/mkzeoinst/__init__.py
===================================================================
--- zope.mkzeoinst/trunk/src/zope/mkzeoinst/__init__.py (rev 0)
+++ zope.mkzeoinst/trunk/src/zope/mkzeoinst/__init__.py 2010-04-22 18:18:04 UTC (rev 111274)
@@ -0,0 +1,243 @@
+##############################################################################
+#
+# Copyright (c) 2003 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""%(program)s -- create a ZEO instance.
+
+Usage: %(program)s home [port]
+
+Given an "instance home directory" <home> and some configuration
+options (all of which have default values), create the following:
+
+<home>/etc/zeo.conf -- ZEO config file
+<home>/var/ -- Directory for data files: Data.fs etc.
+<home>/log/ -- Directory for log files: zeo.log and zeoctl.log
+<home>/bin/runzeo -- the zeo server runner
+<home>/bin/zeoctl -- start/stop script (a shim for zeoctl.py)
+
+The script will not overwrite existing files; instead, it will issue a
+warning if an existing file is found that differs from the file that
+would be written if it didn't exist.
+"""
+
+# WARNING! Several templates and functions here are reused by ZRS.
+# So be careful with changes.
+
+import os
+import sys
+import stat
+import getopt
+
+zeo_conf_template = """\
+# ZEO configuration file
+
+%%define INSTANCE %(instance_home)s
+
+<zeo>
+ address %(port)d
+ read-only false
+ invalidation-queue-size 100
+ # pid-filename $INSTANCE/var/ZEO.pid
+ # monitor-address PORT
+ # transaction-timeout SECONDS
+</zeo>
+
+<filestorage 1>
+ path $INSTANCE/var/Data.fs
+</filestorage>
+
+<eventlog>
+ level info
+ <logfile>
+ path $INSTANCE/log/zeo.log
+ </logfile>
+</eventlog>
+
+<runner>
+ program $INSTANCE/bin/runzeo
+ socket-name $INSTANCE/etc/%(package)s.zdsock
+ daemon true
+ forever false
+ backoff-limit 10
+ exit-codes 0, 2
+ directory $INSTANCE
+ default-to-interactive true
+ # user zope
+ python %(python)s
+ zdrun %(zodb3_home)s/zdaemon/zdrun.py
+
+ # This logfile should match the one in the %(package)s.conf file.
+ # It is used by zdctl's logtail command, zdrun/zdctl doesn't write it.
+ logfile $INSTANCE/log/%(package)s.log
+</runner>
+"""
+
+zeoctl_template = """\
+#!/bin/sh
+# %(PACKAGE)s instance control script
+
+# The following two lines are for chkconfig. On Red Hat Linux (and
+# some other systems), you can copy or symlink this script into
+# /etc/rc.d/init.d/ and then use chkconfig(8) to automatically start
+# %(PACKAGE)s at boot time.
+
+# chkconfig: 345 90 10
+# description: start a %(PACKAGE)s server
+
+PYTHON="%(python)s"
+INSTANCE_HOME="%(instance_home)s"
+ZODB3_HOME="%(zodb3_home)s"
+
+CONFIG_FILE="%(instance_home)s/etc/%(package)s.conf"
+
+PYTHONPATH="$ZODB3_HOME"
+export PYTHONPATH INSTANCE_HOME
+
+ZEOCTL="$ZODB3_HOME/ZEO/zeoctl.py"
+
+exec "$PYTHON" "$ZEOCTL" -C "$CONFIG_FILE" ${1+"$@"}
+"""
+
+runzeo_template = """\
+#!/bin/sh
+# %(PACKAGE)s instance start script
+
+PYTHON="%(python)s"
+INSTANCE_HOME="%(instance_home)s"
+ZODB3_HOME="%(zodb3_home)s"
+
+CONFIG_FILE="%(instance_home)s/etc/%(package)s.conf"
+
+PYTHONPATH="$ZODB3_HOME"
+export PYTHONPATH INSTANCE_HOME
+
+RUNZEO="$ZODB3_HOME/ZEO/runzeo.py"
+
+exec "$PYTHON" "$RUNZEO" -C "$CONFIG_FILE" ${1+"$@"}
+"""
+
+def main():
+ ZEOInstanceBuilder().run()
+ print "All done."
+
+class ZEOInstanceBuilder:
+ def run(self):
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
+ except getopt.error, msg:
+ print msg
+ sys.exit(2)
+ program = os.path.basename(sys.argv[0])
+ if opts:
+ # There's only the help options, so just dump some help:
+ msg = __doc__ % {"program": program}
+ print msg
+ sys.exit()
+ if len(args) not in [1, 2]:
+ print "Usage: %s home [port]" % program
+ sys.exit(2)
+
+ instance_home = args[0]
+ if not os.path.isabs(instance_home):
+ instance_home = os.path.abspath(instance_home)
+
+ for entry in sys.path:
+ if os.path.exists(os.path.join(entry, 'ZODB')):
+ zodb3_home = entry
+ break
+ else:
+ print "Can't find the Zope home (not in sys.path)"
+ sys.exit(2)
+
+ if args[1:]:
+ port = int(args[1])
+ else:
+ port = 8100 # match example in zope.conf
+
+ params = self.get_params(zodb3_home, instance_home, port)
+ self.create(instance_home, params)
+
+ def get_params(self, zodb3_home, instance_home, port):
+ return {
+ "package": "zeo",
+ "PACKAGE": "ZEO",
+ "zodb3_home": zodb3_home,
+ "instance_home": instance_home,
+ "port": port,
+ "python": sys.executable,
+ }
+
+ def create(self, home, params):
+ makedir(home)
+ makedir(home, "etc")
+ makedir(home, "var")
+ makedir(home, "log")
+ makedir(home, "bin")
+ makefile(zeo_conf_template, home, "etc", "zeo.conf", **params)
+ makexfile(zeoctl_template, home, "bin", "zeoctl", **params)
+ makexfile(runzeo_template, home, "bin", "runzeo", **params)
+
+
+def which(program):
+ strpath = os.getenv("PATH")
+ binpath = strpath.split(os.pathsep)
+ for dir in binpath:
+ path = os.path.join(dir, program)
+ if os.path.isfile(path) and os.access(path, os.X_OK):
+ if not os.path.isabs(path):
+ path = os.path.abspath(path)
+ return path
+ raise IOError("can't find %r on path %r" % (program, strpath))
+
+def makedir(*args):
+ path = ""
+ for arg in args:
+ path = os.path.join(path, arg)
+ mkdirs(path)
+ return path
+
+def mkdirs(path):
+ if os.path.isdir(path):
+ return
+ head, tail = os.path.split(path)
+ if head and tail and not os.path.isdir(head):
+ mkdirs(head)
+ os.mkdir(path)
+ print "Created directory", path
+
+def makefile(template, *args, **kwds):
+ path = makedir(*args[:-1])
+ path = os.path.join(path, args[-1])
+ data = template % kwds
+ if os.path.exists(path):
+ f = open(path)
+ olddata = f.read().strip()
+ f.close()
+ if olddata:
+ if olddata != data.strip():
+ print "Warning: not overwriting existing file %r" % path
+ return path
+ f = open(path, "w")
+ f.write(data)
+ f.close()
+ print "Wrote file", path
+ return path
+
+def makexfile(template, *args, **kwds):
+ path = makefile(template, *args, **kwds)
+ umask = os.umask(022)
+ os.umask(umask)
+ mode = 0777 & ~umask
+ if stat.S_IMODE(os.stat(path)[stat.ST_MODE]) != mode:
+ os.chmod(path, mode)
+ print "Changed mode for %s to %o" % (path, mode)
+ return path
More information about the checkins
mailing list