[Checkins] SVN: zc.monitor/tags/0.3.1/ tag zc.monitor 0.3.1

Fred Drake cvs-admin at zope.org
Fri Apr 27 16:17:50 UTC 2012


Log message for revision 125353:
  tag zc.monitor 0.3.1

Changed:
  A   zc.monitor/tags/0.3.1/
  U   zc.monitor/tags/0.3.1/setup.py
  D   zc.monitor/tags/0.3.1/src/zc/monitor/CHANGES.txt
  A   zc.monitor/tags/0.3.1/src/zc/monitor/CHANGES.txt
  D   zc.monitor/tags/0.3.1/src/zc/monitor/__init__.py
  A   zc.monitor/tags/0.3.1/src/zc/monitor/__init__.py
  D   zc.monitor/tags/0.3.1/src/zc/monitor/tests.py
  A   zc.monitor/tags/0.3.1/src/zc/monitor/tests.py
  A   zc.monitor/tags/0.3.1/src/zc/monitor/unix-sockets.txt

-=-
Modified: zc.monitor/tags/0.3.1/setup.py
===================================================================
--- zc.monitor/trunk/setup.py	2012-04-27 15:11:35 UTC (rev 125348)
+++ zc.monitor/tags/0.3.1/setup.py	2012-04-27 16:17:47 UTC (rev 125353)
@@ -8,7 +8,7 @@
 
 setup(
     name = name,
-    version = '0',
+    version = '0.3.1',
     author = 'Jim Fulton',
     author_email = 'jim at zope.com',
     license = 'ZPL 2.1',

Deleted: zc.monitor/tags/0.3.1/src/zc/monitor/CHANGES.txt
===================================================================
--- zc.monitor/trunk/src/zc/monitor/CHANGES.txt	2012-04-27 15:11:35 UTC (rev 125348)
+++ zc.monitor/tags/0.3.1/src/zc/monitor/CHANGES.txt	2012-04-27 16:17:47 UTC (rev 125353)
@@ -1,43 +0,0 @@
-==============
-Change History
-==============
-
-0.3.0 (2011-12-12)
-------------------
-
-- Added a simplified registration interface.
-
-0.2.1 (2011-12-10)
-------------------
-
-- Added an ``address`` option to ``start`` to be able to specify an adapter
-  to bind to.
-
-- ``start`` now returns the address being listened on, which is useful
-  when binding to port 0.
-
-- Using Python's ``doctest`` module instead of depreacted
-  ``zope.testing.doctest``.
-
-
-0.2.0 (2009-10-28)
-------------------
-
-- Add the "MORE" mode so commands can co-opt user interaction
-
-0.1.2 (2008-09-15)
-------------------
-
-- Bugfix: The z3monitor server lacked a handle_close method, which
-  caused errors to get logged when users closed connections before
-  giving commands.
-
-0.1.1 (2008-09-14)
-------------------
-
-- Bugfix: fixed and added test for regression in displaying tracebacks.
-
-0.1.0 (2008-09-14)
-------------------
-
-Initial release

Copied: zc.monitor/tags/0.3.1/src/zc/monitor/CHANGES.txt (from rev 125352, zc.monitor/trunk/src/zc/monitor/CHANGES.txt)
===================================================================
--- zc.monitor/tags/0.3.1/src/zc/monitor/CHANGES.txt	                        (rev 0)
+++ zc.monitor/tags/0.3.1/src/zc/monitor/CHANGES.txt	2012-04-27 16:17:47 UTC (rev 125353)
@@ -0,0 +1,56 @@
+==============
+Change History
+==============
+
+0.3.1 (2012-04-27)
+------------------
+
+- When binding the monitor to a Unix-domain socket, remove an existing
+  socket at the same path so the bind is successful.  This may affect
+  existing usage with respect to zopectl debug behavior, but will be
+  more predictable.
+
+
+0.3.0 (2011-12-12)
+------------------
+
+- Added a simplified registration interface.
+
+
+0.2.1 (2011-12-10)
+------------------
+
+- Added an ``address`` option to ``start`` to be able to specify an adapter
+  to bind to.
+
+- ``start`` now returns the address being listened on, which is useful
+  when binding to port 0.
+
+- Using Python's ``doctest`` module instead of depreacted
+  ``zope.testing.doctest``.
+
+
+0.2.0 (2009-10-28)
+------------------
+
+- Add the "MORE" mode so commands can co-opt user interaction
+
+
+0.1.2 (2008-09-15)
+------------------
+
+- Bugfix: The z3monitor server lacked a handle_close method, which
+  caused errors to get logged when users closed connections before
+  giving commands.
+
+
+0.1.1 (2008-09-14)
+------------------
+
+- Bugfix: fixed and added test for regression in displaying tracebacks.
+
+
+0.1.0 (2008-09-14)
+------------------
+
+Initial release

Deleted: zc.monitor/tags/0.3.1/src/zc/monitor/__init__.py
===================================================================
--- zc.monitor/trunk/src/zc/monitor/__init__.py	2012-04-27 15:11:35 UTC (rev 125348)
+++ zc.monitor/tags/0.3.1/src/zc/monitor/__init__.py	2012-04-27 16:17:47 UTC (rev 125353)
@@ -1,166 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005-2008 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.
-#
-##############################################################################
-"""Zope 3 Monitor Server
-"""
-
-import errno, logging, traceback, socket
-
-import zope.component
-
-import zc.monitor.interfaces
-
-INTERACTIVE_MARKER = object()
-QUIT_MARKER = object()
-MORE_MARKER = object()
-
-class Server:
-
-    last_command = None
-
-    def __init__(self, connection):
-        import zc.ngi.adapters
-        connection = zc.ngi.adapters.Lines(connection)
-        self.connection = connection
-        connection.set_handler(self)
-        self.mode = QUIT_MARKER
-
-    def handle_input(self, connection, data):
-        args = data.strip().split()
-        if self.mode is MORE_MARKER:
-            command_name = self.last_command[0]
-        elif not args:
-            if self.last_command is not None:
-                command_name, args = self.last_command
-            else:
-                return
-        else:
-            command_name = args.pop(0)
-            self.last_command = (command_name, args)
-        command = zope.component.queryUtility(
-            zc.monitor.interfaces.IMonitorPlugin,
-            command_name)
-        if command is None:
-            connection.write(
-                'Invalid command %r\nTry "help".\n' % command_name)
-        else:
-            try:
-                res = command(connection, *args)
-            except Exception, v:
-                traceback.print_exc(100, connection)
-                print >> connection, "%s: %s\n" % (v.__class__.__name__, v)
-            else:
-                if res in (INTERACTIVE_MARKER, QUIT_MARKER, MORE_MARKER):
-                    self.mode = res
-
-        if self.mode is QUIT_MARKER:
-            connection.write(zc.ngi.END_OF_DATA)
-
-    def handle_close(self, connection, reason):
-        pass                            # Don't care
-
-#testing support
-last_listener = None
-
-def start(address):
-    """start monitor server.
-
-    Returns the listener address (which may be different from the
-    given address) if monitor server started; returns False if the
-    port is already in use; and raises an exception otherwise.
-    """
-    import zc.ngi.async
-
-    ourAddress = None
-    if isinstance(address, int):
-        #a port is passed as int
-        ourAddress = ('', address)
-    elif isinstance(address, tuple):
-        #an (address, port) tuple is passed
-        ourAddress = address
-    elif isinstance(address, basestring):
-        #a unix domain socket string is passed
-        ourAddress = address
-
-    try:
-        global last_listener
-        last_listener = zc.ngi.async.listener(ourAddress, Server)
-    except socket.error, e:
-        if e.args[0] == errno.EADDRINUSE:
-            # Don't kill the process just because somebody else has our port.
-            # This might be a zopectl debug or some other innocuous problem.
-            logging.warning(
-                'unable to start zc.monitor server because the address %s '\
-                'is in use.',
-                ourAddress)
-            return False
-        else:
-            raise
-    return last_listener.address
-
-# default commands
-
-def interactive(connection):
-    """Turn on monitor's interactive mode
-
-    Normally, the monitor releases the connection after a single command.
-    By entering the interactive mode, the monitor will not end the connection
-    until you enter the "quit" command.
-
-    In interactive mode, an empty line repeats the last command.
-    """
-    connection.write('Interactive mode on.  Use "quit" To exit.\n')
-    return INTERACTIVE_MARKER
-
-def quit(connection):
-    """Quit the monitor
-
-    This is only really useful in interactive mode (see the "interactive"
-    command).
-    """
-    connection.write('Goodbye.\n')
-    return QUIT_MARKER
-
-def help(connection, command_name=None):
-    """Get help about server commands
-
-    By default, a list of commands and summaries is printed.  Provide
-    a command name to get detailed documentation for a command.
-    """
-    if command_name is None:
-        connection.write(str(
-            "Supported commands:\n  "
-            + '\n  '.join(sorted(
-                "%s -- %s" % (name, (u.__doc__ or '?').split('\n', 1)[0])
-                for (name, u) in
-                zope.component.getUtilitiesFor(
-                    zc.monitor.interfaces.IMonitorPlugin)))
-            + '\n'))
-    else:
-        command = zope.component.getUtility(
-            zc.monitor.interfaces.IMonitorPlugin,
-            command_name)
-        connection.write("Help for %s:\n\n%s\n"
-                         % (command_name, command.__doc__)
-                         )
-
-def register(command, name=None):
-    if name is None:
-        name = command.__name__
-    zope.component.provideUtility(
-        command, zc.monitor.interfaces.IMonitorPlugin, name)
-
-def register_basics():
-    register(help)
-    register(interactive)
-    register(quit)

Copied: zc.monitor/tags/0.3.1/src/zc/monitor/__init__.py (from rev 125352, zc.monitor/trunk/src/zc/monitor/__init__.py)
===================================================================
--- zc.monitor/tags/0.3.1/src/zc/monitor/__init__.py	                        (rev 0)
+++ zc.monitor/tags/0.3.1/src/zc/monitor/__init__.py	2012-04-27 16:17:47 UTC (rev 125353)
@@ -0,0 +1,173 @@
+##############################################################################
+#
+# Copyright (c) 2005-2008 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.
+#
+##############################################################################
+"""Zope 3 Monitor Server
+"""
+
+import errno, logging, os, stat, traceback, socket
+
+import zope.component
+
+import zc.monitor.interfaces
+
+INTERACTIVE_MARKER = object()
+QUIT_MARKER = object()
+MORE_MARKER = object()
+
+class Server:
+
+    last_command = None
+
+    def __init__(self, connection):
+        import zc.ngi.adapters
+        connection = zc.ngi.adapters.Lines(connection)
+        self.connection = connection
+        connection.set_handler(self)
+        self.mode = QUIT_MARKER
+
+    def handle_input(self, connection, data):
+        args = data.strip().split()
+        if self.mode is MORE_MARKER:
+            command_name = self.last_command[0]
+        elif not args:
+            if self.last_command is not None:
+                command_name, args = self.last_command
+            else:
+                return
+        else:
+            command_name = args.pop(0)
+            self.last_command = (command_name, args)
+        command = zope.component.queryUtility(
+            zc.monitor.interfaces.IMonitorPlugin,
+            command_name)
+        if command is None:
+            connection.write(
+                'Invalid command %r\nTry "help".\n' % command_name)
+        else:
+            try:
+                res = command(connection, *args)
+            except Exception, v:
+                traceback.print_exc(100, connection)
+                print >> connection, "%s: %s\n" % (v.__class__.__name__, v)
+            else:
+                if res in (INTERACTIVE_MARKER, QUIT_MARKER, MORE_MARKER):
+                    self.mode = res
+
+        if self.mode is QUIT_MARKER:
+            connection.write(zc.ngi.END_OF_DATA)
+
+    def handle_close(self, connection, reason):
+        pass                            # Don't care
+
+#testing support
+last_listener = None
+
+def start(address):
+    """start monitor server.
+
+    Returns the listener address (which may be different from the
+    given address) if monitor server started; returns False if the
+    port is already in use; and raises an exception otherwise.
+    """
+    import zc.ngi.async
+
+    ourAddress = None
+    if isinstance(address, int):
+        #a port is passed as int
+        ourAddress = ('', address)
+    elif isinstance(address, tuple):
+        #an (address, port) tuple is passed
+        ourAddress = address
+    elif isinstance(address, basestring):
+        #a unix domain socket string is passed
+        ourAddress = address
+        if os.path.exists(ourAddress):
+            m = os.stat(ourAddress)
+            if stat.S_ISSOCK(m.st_mode):
+                os.unlink(ourAddress)
+
+    try:
+        global last_listener
+        last_listener = zc.ngi.async.listener(ourAddress, Server)
+    except socket.error, e:
+        if e.args[0] == errno.EADDRINUSE:
+            # Don't kill the process just because somebody else has our port.
+            # This might be a zopectl debug or some other innocuous problem.
+            # (Existing Unix-domain sockets are removed before binding, so
+            # this doesn't work that way for those.  Use a separate offline
+            # configuration in that case.)
+            logging.warning(
+                'unable to start zc.monitor server because the address %s '\
+                'is in use.',
+                ourAddress)
+            return False
+        else:
+            raise
+    return last_listener.address
+
+# default commands
+
+def interactive(connection):
+    """Turn on monitor's interactive mode
+
+    Normally, the monitor releases the connection after a single command.
+    By entering the interactive mode, the monitor will not end the connection
+    until you enter the "quit" command.
+
+    In interactive mode, an empty line repeats the last command.
+    """
+    connection.write('Interactive mode on.  Use "quit" To exit.\n')
+    return INTERACTIVE_MARKER
+
+def quit(connection):
+    """Quit the monitor
+
+    This is only really useful in interactive mode (see the "interactive"
+    command).
+    """
+    connection.write('Goodbye.\n')
+    return QUIT_MARKER
+
+def help(connection, command_name=None):
+    """Get help about server commands
+
+    By default, a list of commands and summaries is printed.  Provide
+    a command name to get detailed documentation for a command.
+    """
+    if command_name is None:
+        connection.write(str(
+            "Supported commands:\n  "
+            + '\n  '.join(sorted(
+                "%s -- %s" % (name, (u.__doc__ or '?').split('\n', 1)[0])
+                for (name, u) in
+                zope.component.getUtilitiesFor(
+                    zc.monitor.interfaces.IMonitorPlugin)))
+            + '\n'))
+    else:
+        command = zope.component.getUtility(
+            zc.monitor.interfaces.IMonitorPlugin,
+            command_name)
+        connection.write("Help for %s:\n\n%s\n"
+                         % (command_name, command.__doc__)
+                         )
+
+def register(command, name=None):
+    if name is None:
+        name = command.__name__
+    zope.component.provideUtility(
+        command, zc.monitor.interfaces.IMonitorPlugin, name)
+
+def register_basics():
+    register(help)
+    register(interactive)
+    register(quit)

Deleted: zc.monitor/tags/0.3.1/src/zc/monitor/tests.py
===================================================================
--- zc.monitor/trunk/src/zc/monitor/tests.py	2012-04-27 15:11:35 UTC (rev 125348)
+++ zc.monitor/tags/0.3.1/src/zc/monitor/tests.py	2012-04-27 16:17:47 UTC (rev 125353)
@@ -1,21 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004-2008 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.
-#
-##############################################################################
-
-import doctest
-
-def test_suite():
-    return doctest.DocFileSuite(
-        'README.txt',
-        optionflags=doctest.NORMALIZE_WHITESPACE,
-        )

Copied: zc.monitor/tags/0.3.1/src/zc/monitor/tests.py (from rev 125352, zc.monitor/trunk/src/zc/monitor/tests.py)
===================================================================
--- zc.monitor/tags/0.3.1/src/zc/monitor/tests.py	                        (rev 0)
+++ zc.monitor/tags/0.3.1/src/zc/monitor/tests.py	2012-04-27 16:17:47 UTC (rev 125353)
@@ -0,0 +1,28 @@
+##############################################################################
+#
+# Copyright (c) 2004-2008 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.
+#
+##############################################################################
+
+import doctest
+import sys
+import unittest
+
+def test_suite():
+    suite = unittest.TestSuite([
+        doctest.DocFileSuite(
+            'README.txt',
+            optionflags=doctest.NORMALIZE_WHITESPACE,
+            ),
+        ])
+    if not sys.platform.lower().startswith('win'):
+        suite.addTest(doctest.DocFileSuite('unix-sockets.txt'))
+    return suite

Copied: zc.monitor/tags/0.3.1/src/zc/monitor/unix-sockets.txt (from rev 125352, zc.monitor/trunk/src/zc/monitor/unix-sockets.txt)
===================================================================
--- zc.monitor/tags/0.3.1/src/zc/monitor/unix-sockets.txt	                        (rev 0)
+++ zc.monitor/tags/0.3.1/src/zc/monitor/unix-sockets.txt	2012-04-27 16:17:47 UTC (rev 125353)
@@ -0,0 +1,46 @@
+=========================
+Using Unix-domain sockets
+=========================
+
+Passing a string to start causes it to bind to a Unix-domain socket.
+
+Let's set up logging so we can see what's happening:
+
+    >>> import logging
+    >>> import os
+    >>> import stat
+    >>> import time
+    >>> import zc.monitor
+    >>> import zope.testing.loggingsupport
+
+    >>> loghandler = zope.testing.loggingsupport.InstalledHandler(
+    ...     None, level=logging.INFO)
+
+Passing a path as the argument to start causes a Unix socket to be bound:
+
+    >>> path = "testing.sock"
+
+    >>> zc.monitor.start(path)
+    'testing.sock'
+
+    >>> m1 = os.stat(path)
+    >>> stat.S_ISSOCK(m1.st_mode)
+    True
+
+Attempting to start the monitor at the same path again succeeds, but
+causes a new socket to be created:
+
+    >>> zc.monitor.start(path)
+    'testing.sock'
+
+    >>> m2 = os.stat(path)
+    >>> stat.S_ISSOCK(m2.st_mode)
+    True
+
+    >>> m1.st_ino == m2.st_ino
+    False
+
+Clean up:
+
+    >>> os.unlink(path)
+    >>> loghandler.uninstall()



More information about the checkins mailing list