[Zope-Checkins] SVN: Zope/branches/2.12/ - added 'runzope' and 'zopectl' as entry points for instance scripts

Yvo Schubbe y.2009 at wcm-solutions.de
Fri Jul 24 07:28:17 EDT 2009


Log message for revision 102230:
  - added 'runzope' and 'zopectl' as entry points for instance scripts
  - made instance scripts more suitable for egg based installs
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/doc/WINDOWS.rst
  U   Zope/branches/2.12/setup.py
  UU  Zope/branches/2.12/src/Zope2/utilities/mkzopeinstance.py
  UU  Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.bat.in
  UU  Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.in
  UU  Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.bat.in
  UU  Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.in
  UU  Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopeservice.py.in

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst	2009-07-24 11:15:02 UTC (rev 102229)
+++ Zope/branches/2.12/doc/CHANGES.rst	2009-07-24 11:28:16 UTC (rev 102230)
@@ -15,9 +15,14 @@
 
   - zope.testing = 3.7.7
 
+- scripts: Added 'runzope' and 'zopectl' as entry points for instance scripts.
+
 Bugs Fixed
 ++++++++++
 
+- mkzopeinstance: Made instance scripts more suitable for egg based installs.
+  If you are using a customized skel, it has to be updated.
+
 - Five: Fixed the permissions creation feature added in Zope 2.12.0a2.
 
 - LP #399633: fixed interpreter paths

Modified: Zope/branches/2.12/doc/WINDOWS.rst
===================================================================
--- Zope/branches/2.12/doc/WINDOWS.rst	2009-07-24 11:15:02 UTC (rev 102229)
+++ Zope/branches/2.12/doc/WINDOWS.rst	2009-07-24 11:28:16 UTC (rev 102230)
@@ -38,7 +38,7 @@
   username/password for the admin user.
 
 * We are now ready to start zope.  Run:
-  % {zope_instance}\run_zope.bat.
+  % {zope_instance}\bin\runzope.bat
   Zope should start with nice log messages being printed to
   stdout.  When Zope is ready, you should see:
   > ------
@@ -47,11 +47,12 @@
   Press Ctrl+C to stop this instance of the server.
 
 * Optionally, install as a Windows service.  Execute:
-  % python {zope_instance}\zope_service.py
+  % python {zope_instance}\bin\zopeservice.py
   to see the valid options.  You may want something like:
-  % python {zope_instance}\zope_service.py --startup=auto install
+  % python {zope_instance}\bin\zopeservice.py --startup=auto install
 
   Once installed, it can be started any number of ways:
-  - python {zope_instance}\zope_service.py start
+  - % {zope_instance}\bin\zopectl.bat start
+  - % python {zope_instance}\bin\zopeservice.py start
   - Control Panel
-  - net start service_short_name (eg, `net start Zope_-1227678699`)
+  - % net start service_short_name (eg, `net start Zope_-1227678699`)

Modified: Zope/branches/2.12/setup.py
===================================================================
--- Zope/branches/2.12/setup.py	2009-07-24 11:15:02 UTC (rev 102229)
+++ Zope/branches/2.12/setup.py	2009-07-24 11:28:16 UTC (rev 102230)
@@ -143,6 +143,8 @@
        'console_scripts' : [
           'mkzeoinstance=Zope2.utilities.mkzeoinstance:main',
           'mkzopeinstance=Zope2.utilities.mkzopeinstance:main',
+          'runzope=Zope2.Startup.run:run',
+          'zopectl=Zope2.Startup.zopectl:run',
           'zpasswd=Zope2.utilities.zpasswd:main',
       ]
     },

Modified: Zope/branches/2.12/src/Zope2/utilities/mkzopeinstance.py
===================================================================
--- Zope/branches/2.12/src/Zope2/utilities/mkzopeinstance.py	2009-07-24 11:15:02 UTC (rev 102229)
+++ Zope/branches/2.12/src/Zope2/utilities/mkzopeinstance.py	2009-07-24 11:28:16 UTC (rev 102230)
@@ -41,15 +41,15 @@
         usage(sys.stderr, msg)
         sys.exit(2)
 
-    script = os.path.abspath(sys.argv[0])
+    script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
     user = None
     password = None
     skeltarget = None
     skelsrc = None
     python = None
 
-    if check_buildout():
-        python = os.path.abspath('bin/zopepy')
+    if check_buildout(script_path):
+        python = os.path.join(script_path, 'zopepy')
 
     for opt, arg in opts:
         if opt in ("-d", "--dir"):
@@ -127,6 +127,7 @@
         "PYTHON":PYTHON,
         "PYTHONW":PYTHONW,
         "INSTANCE_HOME": instancehome,
+        "ZOPE_SCRIPTS": script_path,
         "ZOPE2PATH": zope2path,
         }
 
@@ -186,24 +187,30 @@
     fp.close()
     os.chmod(fn, 0644)
 
-def check_buildout():
+def check_buildout(script_path):
     """ Are we running from within a buildout which supplies 'zopepy'?
     """
-    if os.path.exists('buildout.cfg'):
+    buildout_cfg = os.path.join(os.path.dirname(script_path), 'buildout.cfg')
+    if os.path.exists(buildout_cfg):
         from ConfigParser import RawConfigParser
         parser = RawConfigParser()
-        parser.read('buildout.cfg')
+        parser.read(buildout_cfg)
         return 'zopepy' in parser.sections()
 
 def get_zope2path(python):
     """ Get Zope2 path from selected Python interpreter.
     """
-    p = os.popen('"%s" -c"import os, Zope2; '
-        'print os.path.realpath(os.path.dirname(Zope2.__file__))"' % python)
+    zope2file = ''
+    p = os.popen('"%s" -c"import Zope2; print Zope2.__file__"' % python)
     try:
-        return p.readline()[:-1]
+        zope2file = p.readline()[:-1]
     finally:
         p.close()
+    if not zope2file:
+        # fall back to current Python interpreter
+        import Zope2
+        zope2file = Zope2.__file__
+    return os.path.abspath(os.path.dirname(os.path.dirname(zope2file)))
 
 if __name__ == "__main__":
     main()


Property changes on: Zope/branches/2.12/src/Zope2/utilities/mkzopeinstance.py
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
   - 1.8

Modified: Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.bat.in
===================================================================
--- Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.bat.in	2009-07-24 11:15:02 UTC (rev 102229)
+++ Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.bat.in	2009-07-24 11:28:16 UTC (rev 102230)
@@ -1,5 +1,5 @@
- at set PYTHON=<<PYTHON>>
 @set INSTANCE_HOME=<<INSTANCE_HOME>>
 @set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf
- at set ZOPE_RUN=<<ZOPE2PATH>>\Startup\run.py
-"%PYTHON%" "%ZOPE_RUN%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
+ at set ZOPE_RUN=<<ZOPE_SCRIPTS>>\runzope
+
+"%ZOPE_RUN%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7


Property changes on: Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.bat.in
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
   - 1.3

Modified: Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.in
===================================================================
--- Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.in	2009-07-24 11:15:02 UTC (rev 102229)
+++ Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.in	2009-07-24 11:28:16 UTC (rev 102230)
@@ -1,10 +1,8 @@
 #! /bin/sh
 
-PYTHON="<<PYTHON>>"
 INSTANCE_HOME="<<INSTANCE_HOME>>"
 CONFIG_FILE="<<INSTANCE_HOME>>/etc/zope.conf"
+ZOPE_RUN="<<ZOPE_SCRIPTS>>/runzope"
 export INSTANCE_HOME
 
-ZOPE_RUN="<<ZOPE2PATH>>/Startup/run.py"
-
-exec "$PYTHON" "$ZOPE_RUN" -C "$CONFIG_FILE" "$@"
+exec "$ZOPE_RUN" -C "$CONFIG_FILE" "$@"


Property changes on: Zope/branches/2.12/src/Zope2/utilities/skel/bin/runzope.in
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
   - 1.7

Modified: Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.bat.in
===================================================================
--- Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.bat.in	2009-07-24 11:15:02 UTC (rev 102229)
+++ Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.bat.in	2009-07-24 11:28:16 UTC (rev 102230)
@@ -1,5 +1,6 @@
 @set PYTHON=<<PYTHON>>
 @set INSTANCE_HOME=<<INSTANCE_HOME>>
 @set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf
- at set ZDCTL=<<ZOPE2PATH>>\Startup\zopectl.py
-"%PYTHON%" "%ZDCTL%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
+ at set ZDCTL=<<ZOPE_SCRIPTS>>\zopectl
+
+"%ZDCTL%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7


Property changes on: Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.bat.in
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
   - 1.3

Modified: Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.in
===================================================================
--- Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.in	2009-07-24 11:15:02 UTC (rev 102229)
+++ Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.in	2009-07-24 11:28:16 UTC (rev 102230)
@@ -3,9 +3,8 @@
 PYTHON="<<PYTHON>>"
 INSTANCE_HOME="<<INSTANCE_HOME>>"
 CONFIG_FILE="<<INSTANCE_HOME>>/etc/zope.conf"
+ZDCTL="<<ZOPE_SCRIPTS>>/zopectl"
 export INSTANCE_HOME
 export PYTHON
 
-ZDCTL="<<ZOPE2PATH>>/Startup/zopectl.py"
-
-exec "$PYTHON" "$ZDCTL" -C "$CONFIG_FILE" "$@"
+exec "$ZDCTL" -C "$CONFIG_FILE" "$@"


Property changes on: Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopectl.in
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
   - 1.7

Modified: Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopeservice.py.in
===================================================================
--- Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopeservice.py.in	2009-07-24 11:15:02 UTC (rev 102229)
+++ Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopeservice.py.in	2009-07-24 11:28:16 UTC (rev 102230)
@@ -81,15 +81,19 @@
 import sys, os
 
 # these are replacements from mkzopeinstance
-PYTHON = r'<<PYTHON>>'
 INSTANCE_HOME = r'<<INSTANCE_HOME>>'
+ZOPE_SCRIPTS = r'<<ZOPE_SCRIPTS>>'
+ZOPE2PATH = r'<<ZOPE2PATH>>'
 
-ZOPE_RUN = r'<<ZOPE2PATH>>\Startup\run.py'
-CONFIG_FILE= os.path.join(INSTANCE_HOME, 'etc', 'zope.conf')
-PYTHONSERVICE_EXE=r'%s\bin\PythonService.exe' % ZOPE_HOME
+ZOPE_RUN = os.path.join(ZOPE_SCRIPTS, 'runzope')
+CONFIG_FILE = os.path.join(INSTANCE_HOME, 'etc', 'zope.conf')
+PYTHONSERVICE_EXE = os.path.join(ZOPE_SCRIPTS, 'PythonService.exe')
 
 os.environ["INSTANCE_HOME"] = INSTANCE_HOME
 
+# XXX: we need to find nt_svcutils.service
+sys.path[0:0] = [ZOPE2PATH]
+
 from nt_svcutils.service import Service
 
 servicename = 'Zope_%s' % str(hash(INSTANCE_HOME.lower()))
@@ -105,8 +109,8 @@
     if os.path.isfile(PYTHONSERVICE_EXE):
         _exe_name_ = PYTHONSERVICE_EXE
 
-    process_runner = PYTHON
-    process_args = '"%s" -C "%s"' % (ZOPE_RUN, CONFIG_FILE)
+    process_runner = ZOPE_RUN
+    process_args = '-C "%s"' % CONFIG_FILE
 
 if __name__ == '__main__':
     import win32serviceutil


Property changes on: Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopeservice.py.in
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
   - 1.2



More information about the Zope-Checkins mailing list