[Checkins] SVN: zc.zk/trunk/src/zc/zk/ Made the check script quieter.

jim cvs-admin at zope.org
Mon Jun 25 19:47:29 UTC 2012


Log message for revision 127069:
  Made the check script quieter.
  

Changed:
  U   zc.zk/trunk/src/zc/zk/README.txt
  U   zc.zk/trunk/src/zc/zk/monitor.py
  U   zc.zk/trunk/src/zc/zk/monitor.test

-=-
Modified: zc.zk/trunk/src/zc/zk/README.txt
===================================================================
--- zc.zk/trunk/src/zc/zk/README.txt	2012-06-25 11:24:01 UTC (rev 127068)
+++ zc.zk/trunk/src/zc/zk/README.txt	2012-06-25 19:47:25 UTC (rev 127069)
@@ -1165,7 +1165,7 @@
 Change History
 ==============
 
-0.9.0 (2012-06-22)
+0.9.0 (2012-06-25)
 ------------------
 
 - Added support for discovering and testing ephemeral addresses using

Modified: zc.zk/trunk/src/zc/zk/monitor.py
===================================================================
--- zc.zk/trunk/src/zc/zk/monitor.py	2012-06-25 11:24:01 UTC (rev 127068)
+++ zc.zk/trunk/src/zc/zk/monitor.py	2012-06-25 19:47:25 UTC (rev 127069)
@@ -13,8 +13,11 @@
 ##############################################################################
 
 import json
+import logging
 import sys
 
+logger = logging.getLogger(__name__)
+
 _servers = []
 
 def notify(event):
@@ -49,16 +52,20 @@
 
     [addr, path] = args
 
-    sock = _connect(addr)
+    try:
+        sock = _connect(addr)
 
-    sock.sendall('servers %s\n' % path)
-    f = sock.makefile()
-    addr = f.readline()
+        sock.sendall('servers %s\n' % path)
+        f = sock.makefile()
+        addr = f.readline()
 
-    f.close()
-    sock.close()
+        f.close()
+        sock.close()
 
-    _connect(addr).close()
+        _connect(addr).close()
+    except Exception:
+        logger.debug("Failed check", exc_info=True)
+        sys.exit(1)
 
 def get_addr(args=None):
     if args is None:

Modified: zc.zk/trunk/src/zc/zk/monitor.test
===================================================================
--- zc.zk/trunk/src/zc/zk/monitor.test	2012-06-25 11:24:01 UTC (rev 127068)
+++ zc.zk/trunk/src/zc/zk/monitor.test	2012-06-25 19:47:25 UTC (rev 127069)
@@ -68,13 +68,23 @@
 
     >>> s.close()
 
-check will error:
+check will (almost) silently exit with a non-zero exit code:
 
+    >>> from zope.testing import loggingsupport
+    >>> handler = loggingsupport.InstalledHandler('zc.zk.monitor')
     >>> zc.zk.monitor.check((':%s /test/server' % monitor_port).split())
     Traceback (most recent call last):
     ...
-    error: [Errno 111] Connection refused
+    SystemExit: 1
 
+The monitor logs failure info at DEBUG level for debugging, if necessary:
+
+    >>> print handler
+    zc.zk.monitor DEBUG
+      Failed check
+
+    >>> handler.uninstall()
+
 This will, of course, cause it to exit with a non-zero status when run
 as an actual script.
 



More information about the checkins mailing list