[Python-checkins] r47052 - in sandbox/trunk/pdb: mconnection.py mpdb.py test/Makefile

matt.fleming python-checkins at python.org
Wed Jun 21 15:14:22 CEST 2006


Author: matt.fleming
Date: Wed Jun 21 15:14:22 2006
New Revision: 47052

Modified:
   sandbox/trunk/pdb/mconnection.py
   sandbox/trunk/pdb/mpdb.py
   sandbox/trunk/pdb/test/Makefile
Log:
Stop mixing tabs and spaces. Also allow 'make all' to make all tests (sticking
with Makefile convention). Incorporate changes in pydb into our code so that
we can start using 'info target' command.


Modified: sandbox/trunk/pdb/mconnection.py
==============================================================================
--- sandbox/trunk/pdb/mconnection.py	(original)
+++ sandbox/trunk/pdb/mconnection.py	Wed Jun 21 15:14:22 2006
@@ -80,7 +80,7 @@
         self.input.close()
 
     def readline(self, bufsize=2048):
-        line = self.input.recv(bufsize)
+        line = self.input.readline(bufsize)
         return line
 
     def write(self, msg):

Modified: sandbox/trunk/pdb/mpdb.py
==============================================================================
--- sandbox/trunk/pdb/mpdb.py	(original)
+++ sandbox/trunk/pdb/mpdb.py	Wed Jun 21 15:14:22 2006
@@ -45,18 +45,19 @@
         self.prompt = '(MPdb)'
         self.target = 'local'  # local connections by default
         self.connection = None
+        print self._info_cmds
 
     def _rebind_input(self, new_input):
-	""" This method rebinds the debugger's input to the object specified
-	by 'new_input'.
-	"""
+        """ This method rebinds the debugger's input to the object specified
+        by 'new_input'.
+        """
         self.use_rawinput = False
-	self.stdin = new_input
+        self.stdin = new_input
 
     def  _rebind_output(self, new_output):
-	""" This method rebinds the debugger's output to the object specified
-	by 'new_output'.
-	"""
+        """ This method rebinds the debugger's output to the object specified
+        by 'new_output'.
+        """
         self.stdout.flush()
         self.stdout = new_output
 
@@ -69,7 +70,7 @@
         # The output from the command that we've just sent to the server
         # is returned along with the prompt of that server. So we keep reading
         # until we find our prompt.
-        while "(MPdb)" not in ret:
+        while self.prompt not in ret:
             ret += self.connection.readline()
         self.msg_nocr(ret)
         return
@@ -88,9 +89,21 @@
                 out = self.stdout
             print >> out, msg,
 
+    def do_info(self, arg):
+        """Extends pydb do_info() to give info about the Mpdb extensions."""
+        if not arg:
+            pydb.Pdb.do_info(self, arg)
+            return
+
+        args = arg.split()
+        if 'target'.startswith(args[0]):
+            self.msg("target is %s" % self.target)
+        else:
+            pydb.Pdb.do_info(self, arg)
+
     # Debugger commands
     def do_attach(self, addr):
-	""" Attach to a process or file outside of Pdb.
+        """ Attach to a process or file outside of Pdb.
 This command attaches to another target, of the same type as your last
 "target" command. The command may take as argument a process id or a
 device file. For a process id, you must have permission to send the
@@ -102,18 +115,18 @@
 to specify the program, and to load its symbol table.
 """
     def do_target(self, args):
-	""" Connect to a target machine or process.
+        """ Connect to a target machine or process.
 The first argument is the type or protocol of the target machine
-(which can be the name of a class that is avaible either in the current
-working directory or in Python's PYTHONPATH environtment variable).
+(which can be the name of a class that is available either in the current
+working directory or in Python's PYTHONPATH environment variable).
 Remaining arguments are interpreted by the target protocol.  For more
 information on the arguments for a particular protocol, type
 `help target ' followed by the protocol name.
 
 List of target subcommands:
 
-target serial -- Use a remote computer via a serial line
-target tcp -- Use a remote computer via a socket connection
+target serial device-name -- Use a remote computer via a serial line
+target tcp hostname:port -- Use a remote computer via a socket connection
 """
         try:
             target, addr = args.split(' ')
@@ -128,11 +141,14 @@
             if self.connection: self.connection.disconnect()
             try:
                 from mconnection import MClientConnectionTCP
+                # Matt - Where are the connection parameters? 
                 self.connection = MClientConnectionTCP()
+                    
             except ImportError:
                 self.msg('Could not import MClientConnectionTCP')
                 return
         elif target == 'serial':
+            # Matt - Where are the connection parameters? 
             if self.connection: self.connection.disconnect()
             try:
                 from mconnection import MClientConnectionSerial
@@ -154,7 +170,13 @@
                     self.msg('Unknown target type')
                     return
             self.connection = eval(target+'()')
-        self.connection.connect(addr)
+        try: 
+            self.connection.connect(addr)
+        except socket.error:
+            # Matt: I couldn't figure out what the right
+            # exception name was to use that getts the error message.
+            self.msg("Failed to connect to %s" % addr)
+            return
         # This interpreter no longer interprets commands but sends
         # them straight across this object's connection to a server.
         self.prompt = "" # Get our prompt from the server now

Modified: sandbox/trunk/pdb/test/Makefile
==============================================================================
--- sandbox/trunk/pdb/test/Makefile	(original)
+++ sandbox/trunk/pdb/test/Makefile	Wed Jun 21 15:14:22 2006
@@ -6,12 +6,15 @@
 # 
 # or 'make target' to run a specific test, such as 'make tcptest'
 
-PY = python2.5
+PY = python2.4
+
+.PHONY: all test mpdbtest tcptest
+all: test
 
 test: mpdbtest tcptest
 
 mpdbtest:
-	$(PY) mpdbtest.py
+	@$(PY) mpdbtest.py
 
 tcptest:
-	$(PY) tcptest.py
+	@$(PY) tcptest.py


More information about the Python-checkins mailing list