r439 - in zope-common/trunk: . debian

Fabio Tranchitella kobold at alioth.debian.org
Thu Nov 2 17:20:53 CET 2006


Author: kobold
Date: 2006-11-02 17:20:52 +0100 (Thu, 02 Nov 2006)
New Revision: 439

Modified:
   zope-common/trunk/debian/changelog
   zope-common/trunk/dzhandle
Log:
Fixes for #385882, #392653, #388253 and #378364.


Modified: zope-common/trunk/debian/changelog
===================================================================
--- zope-common/trunk/debian/changelog	2006-11-02 15:46:37 UTC (rev 438)
+++ zope-common/trunk/debian/changelog	2006-11-02 16:20:52 UTC (rev 439)
@@ -5,8 +5,10 @@
   * debian/templates: fixed two typos. (Closes: #385882)
   * debian/control: sb-release and po-debconf should be in Build-Depends.
     (Closes: #392653)
+  * dzhandle: restart only running instances on upgrades.
+    (Closes: #388253, #378364)
 
- -- Fabio Tranchitella <kobold at debian.org>  Thu,  2 Nov 2006 15:22:13 +0100
+ -- Fabio Tranchitella <kobold at debian.org>  Thu,  2 Nov 2006 17:15:43 +0100
 
 zope-common (0.5.25) unstable; urgency=low
 

Modified: zope-common/trunk/dzhandle
===================================================================
--- zope-common/trunk/dzhandle	2006-11-02 15:46:37 UTC (rev 438)
+++ zope-common/trunk/dzhandle	2006-11-02 16:20:52 UTC (rev 439)
@@ -3,6 +3,8 @@
 import fnmatch, glob, os, re, sys, shutil
 import pwd, grp
 import logging
+import subprocess
+
 from optparse import OptionParser
 
 program = os.path.basename(sys.argv[0])
@@ -1214,14 +1216,14 @@
         return self.errors_occured
 
     def run(self, global_options):
-        import subprocess
         for zversion in available_zope_versions():
             zope = filter_zope_version(version=zversion)
             pattern = os.path.join(zope['instance'], '*', 'var', 'restart-pending')
             for pending in glob.glob(pattern):
                 home = os.path.dirname(os.path.dirname(pending))
                 instance = ZopeInstance(home, zope['version'])
-                instance.zopectl('restart')
+                if instance.is_running():
+                    instance.zopectl('restart')
                 os.unlink(pending)
 
         # compatibility with old 2.6 installations
@@ -1429,7 +1431,6 @@
         return self.errors_occured
 
     def run(self, global_options):
-        import subprocess
         if self.zversion.startswith('2.'):
             cmd = [os.path.join(self.zope['prefix'], 'bin', 'mkzopeinstance.py')]
         else:
@@ -1508,7 +1509,6 @@
         return self.errors_occured
 
     def run(self, global_options):
-        import subprocess
         if self.zversion.startswith('2.'):
             cmd = [os.path.join(self.zope['prefix'], 'bin', 'mkzeoinstance.py')]
         else:
@@ -1541,7 +1541,6 @@
         return self.errors_occured
 
     def run(self, global_options):
-        import subprocess
         cmd = ["rm", "-rf", 
                self.instance.home + "/Products",
                self.instance.home + "/Extensions",
@@ -1571,7 +1570,6 @@
         return self.errors_occured
 
     def run(self, global_options):
-        import subprocess
         cmd = ["rm", "-rf", 
                self.instance.home,
                "/etc/zope%s/%s" % (self.instance.version, self.instance.name),
@@ -1599,7 +1597,6 @@
         return self.errors_occured
 
     def run(self, global_options):
-        import subprocess
         cmd = ["rm", "-rf", 
                self.instance.home]
         rv = subprocess.call(cmd)
@@ -1874,9 +1871,12 @@
         if self.restart_policy:
             policy = self.restart_policy
 
+        if not self.is_running():
+            return
+
         if policy == 'manually':
             return
-        elif policy == 'end':
+        elif policy == 'end' and self.is_running():
             fd = file(os.path.join(self.home, 'var', 'restart-pending'), 'a+')
             fd.write(reason + '\n')
             fd.close()
@@ -1884,11 +1884,13 @@
             rv = self.zopectl('restart')
             if rv:
                 sys.exit(rv)
-        else:
-            pass
 
+    def is_running(self):
+        cmd = [os.path.join(self.home, 'bin', 'zopectl'), 'status']
+        return "program running;" in subprocess.Popen(args=cmd,
+            stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
+
     def zopectl(self, *args):
-        import subprocess
         cmd = [os.path.join(self.home, 'bin', 'zopectl')]
         os.chdir(self.home)
         if args and isinstance(args[0], list):
@@ -1921,8 +1923,12 @@
         self.name = os.path.basename(home)
         self.version = version
 
+    def is_running(self):
+        cmd = [os.path.join(self.home, 'bin', 'zeoctl'), 'status']
+        return not "not running" in subprocess.Popen(args=cmd,
+            stdout=subprocess.PIPE, stderr=subprocess.STDOUT).read()
+
     def zeoctl(self, *args):
-        import subprocess
         cmd = [os.path.join(self.home, 'bin', 'zeoctl')]
         os.chdir(self.home)
         if args and isinstance(args[0], list):




More information about the pkg-zope-commits mailing list