[Neo-report] r2686 jm - in /trunk/neo: admin/ client/ lib/ master/ storage/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Mar 23 11:45:00 CET 2011


Author: jm
Date: Wed Mar 23 11:44:59 2011
New Revision: 2686

Log:
Rename neo.lib.live_debug to neo.lib.debug

Added:
    trunk/neo/lib/debug.py
      - copied, changed from r2685, trunk/neo/lib/live_debug.py
Removed:
    trunk/neo/lib/live_debug.py
Modified:
    trunk/neo/admin/app.py
    trunk/neo/client/app.py
    trunk/neo/master/app.py
    trunk/neo/storage/app.py
    trunk/neo/tests/__init__.py

Modified: trunk/neo/admin/app.py
==============================================================================
--- trunk/neo/admin/app.py [iso-8859-1] (original)
+++ trunk/neo/admin/app.py [iso-8859-1] Wed Mar 23 11:44:59 2011
@@ -27,7 +27,7 @@ from neo.lib.connector import getConnect
 from neo.lib.bootstrap import BootstrapManager
 from neo.lib.pt import PartitionTable
 from neo.lib.protocol import NodeTypes, NodeStates, Packets, Errors
-from neo.lib.live_debug import register as registerLiveDebugger
+from neo.lib.debug import register as registerLiveDebugger
 
 class Dispatcher:
     """Dispatcher use to redirect master request to handler"""

Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Wed Mar 23 11:44:59 2011
@@ -46,7 +46,7 @@ from neo.client.mq import MQ
 from neo.client.pool import ConnectionPool
 from neo.lib.util import u64, parseMasterList
 from neo.lib.profiling import profiler_decorator, PROFILING_ENABLED
-from neo.lib.live_debug import register as registerLiveDebugger
+from neo.lib.debug import register as registerLiveDebugger
 from neo.client.mq_index import RevisionIndex
 from neo.client.container import ThreadContainer, TransactionContainer
 

Copied: trunk/neo/lib/debug.py (from r2685, trunk/neo/lib/live_debug.py)
==============================================================================
--- trunk/neo/lib/live_debug.py [iso-8859-1] (original)
+++ trunk/neo/lib/debug.py [iso-8859-1] Wed Mar 23 11:44:59 2011
@@ -29,7 +29,7 @@ import neo
 ENABLED = False
 
 # How to include in python code:
-#   from neo.live_debug import register
+#   from neo.debug import register
 #   register()
 #
 # How to trigger it:

Removed: trunk/neo/lib/live_debug.py
==============================================================================
--- trunk/neo/lib/live_debug.py [iso-8859-1] (original)
+++ trunk/neo/lib/live_debug.py (removed)
@@ -1,117 +0,0 @@
-#
-# Copyright (C) 2010  Nexedi SA
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-import traceback
-import signal
-import ctypes
-import imp
-import os
-from functools import wraps
-import neo
-
-# WARNING: This module should only be used for live application debugging.
-# It - by purpose - allows code injection in a running neo process.
-# You don't want to enable it in a production environment. Really.
-ENABLED = False
-
-# How to include in python code:
-#   from neo.live_debug import register
-#   register()
-#
-# How to trigger it:
-#   Kill python process with:
-#     SIGUSR1:
-#       Loads (or reloads) neo.debug module.
-#       The content is up to you (it's only imported).
-#     SIGUSR2:
-#       Triggers a pdb prompt on process' controlling TTY.
-
-libc = ctypes.cdll.LoadLibrary('libc.so.6')
-errno = ctypes.c_int.in_dll(libc, 'errno')
-
-def decorate(func):
-    def decorator(sig, frame):
-        # Save errno value, to restore it after sig handler returns
-        old_errno = errno.value
-        try:
-            func(sig, frame)
-        except:
-            # Prevent exception from exiting signal handler, so mistakes in
-            # "debug" module don't kill process.
-            traceback.print_exc()
-        errno.value = old_errno
-    return wraps(func)(decorator)
-
- at decorate
-def debugHandler(sig, frame):
-    file, filename, (suffix, mode, type) = imp.find_module('debug',
-        neo.__path__)
-    imp.load_module('neo.debug', file, filename, (suffix, mode, type))
-
-_debugger = None
-
- at decorate
-def pdbHandler(sig, frame):
-    try:
-        import rpdb2
-    except ImportError:
-        global _debugger
-        if _debugger is None:
-            try: # try ipython if available
-                import IPython
-                IPython.Shell.IPShell(argv=[])
-                _debugger = IPython.Debugger.Tracer().debugger
-            except ImportError:
-                import pdb
-                _debugger = pdb.Pdb()
-        return debugger.set_trace(frame)
-    # WKRD: rpdb2 take an integer (depth) instead of a frame as parameter,
-    #       so we must hardcode the value, taking the decorator into account
-    if rpdb2.g_debugger is not None:
-        return rpdb2.setbreak(2)
-    script = rpdb2.calc_frame_path(frame)
-    pwd = os.getcwd().replace('/', '_').replace('-', '_')
-    pid = os.fork()
-    if pid:
-        try:
-            rpdb2.start_embedded_debugger(pwd, depth=2)
-        finally:
-            os.waitpid(pid, 0)
-    else:
-        try:
-            os.execlp('python', 'python', '-c', """import os\nif not os.fork():
-                import rpdb2, winpdb
-                rpdb2_raw_input = rpdb2._raw_input
-                rpdb2._raw_input = lambda s: \
-                    s == rpdb2.STR_PASSWORD_INPUT and %r or rpdb2_raw_input(s)
-                winpdb.g_ignored_warnings[winpdb.STR_EMBEDDED_WARNING] = True
-                winpdb.main()
-            """ % pwd, '-a', script)
-        finally:
-            os.abort()
-
-def register(on_log=None):
-    if ENABLED:
-        signal.signal(signal.SIGUSR1, debugHandler)
-        signal.signal(signal.SIGUSR2, pdbHandler)
-        if on_log is not None:
-            # use 'kill -RTMIN <pid>
-            @decorate
-            def on_log_signal(signum, signal):
-                on_log()
-            signal.signal(signal.SIGRTMIN, on_log_signal)
-

Modified: trunk/neo/master/app.py
==============================================================================
--- trunk/neo/master/app.py [iso-8859-1] (original)
+++ trunk/neo/master/app.py [iso-8859-1] Wed Mar 23 11:44:59 2011
@@ -36,7 +36,7 @@ from neo.master.recovery import Recovery
 from neo.lib.util import dump
 from neo.lib.connector import getConnectorHandler
 
-from neo.lib.live_debug import register as registerLiveDebugger
+from neo.lib.debug import register as registerLiveDebugger
 
 class Application(object):
     """The master node application."""

Modified: trunk/neo/storage/app.py
==============================================================================
--- trunk/neo/storage/app.py [iso-8859-1] (original)
+++ trunk/neo/storage/app.py [iso-8859-1] Wed Mar 23 11:44:59 2011
@@ -35,7 +35,7 @@ from neo.lib.pt import PartitionTable
 from neo.lib.util import dump
 from neo.lib.bootstrap import BootstrapManager
 
-from neo.lib.live_debug import register as registerLiveDebugger
+from neo.lib.debug import register as registerLiveDebugger
 
 class Application(object):
     """The storage node application."""

Modified: trunk/neo/tests/__init__.py
==============================================================================
--- trunk/neo/tests/__init__.py [iso-8859-1] (original)
+++ trunk/neo/tests/__init__.py [iso-8859-1] Wed Mar 23 11:44:59 2011
@@ -26,7 +26,7 @@ import MySQLdb
 import neo
 
 from mock import Mock
-from neo.lib import live_debug, logger, protocol
+from neo.lib import debug, logger, protocol
 from neo.lib.protocol import Packets
 from neo.lib.util import getAddressType
 from time import time, gmtime, sleep
@@ -44,10 +44,10 @@ IP_VERSION_FORMAT_DICT = {
 
 ADDRESS_TYPE = socket.AF_INET
 
-live_debug.ENABLED = True
-live_debug.register()
+debug.ENABLED = True
+debug.register()
 # prevent "signal only works in main thread" errors in subprocesses
-live_debug.ENABLED = False
+debug.ENABLED = False
 logger.PACKET_LOGGER.enable(True)
 
 def buildUrlFromString(address):




More information about the Neo-report mailing list